Finding Predictors: Nearest Neighbor Modern Motivations: Be Lazy! - - PowerPoint PPT Presentation

finding predictors nearest neighbor modern motivations be
SMART_READER_LITE
LIVE PREVIEW

Finding Predictors: Nearest Neighbor Modern Motivations: Be Lazy! - - PowerPoint PPT Presentation

Finding Predictors: Nearest Neighbor Modern Motivations: Be Lazy! Classification Regression Choosing the right number of neighbors Some Optimizations Other types of lazy algorithms Compendium slides for Guide to Intelligent Data


slide-1
SLIDE 1

Finding Predictors: Nearest Neighbor Modern Motivations: Be Lazy!

Classification Regression Choosing the right number of neighbors

Some Optimizations Other types of lazy algorithms

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

1 / 49

slide-2
SLIDE 2

Motivation: A Zoo

Given: Information about animals in the zoo How can we classify new animals?

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

2 / 49

slide-3
SLIDE 3

Motivation: A Zoo

Given: Information about animals in the zoo How can we classify new animals?

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

2 / 49

slide-4
SLIDE 4

Motivation: A Zoo

Given: Information about animals in the zoo How can we classify new animals?

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

2 / 49

slide-5
SLIDE 5

Motivation: A Zoo

Given: Information about animals in the zoo How can we classify new animals?

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

2 / 49

slide-6
SLIDE 6

Motivation: A Zoo

Given: Information about animals in the zoo How can we classify new animals?

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

2 / 49

slide-7
SLIDE 7

Remember ?

Unsupervised vs. Supervised Learning

Unsupervised: No class information given. Goal: detect unknown patterns (e.g. clusters, association rules) Supervised: Class information exists/is provided by supervisor. Goal: learn class structure for future unclassified/unknown data.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

3 / 49

slide-8
SLIDE 8

Motivation: Expert/Legal Systems/Streber

How do Expert Systems work?

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

4 / 49

slide-9
SLIDE 9

Motivation: Expert/Legal Systems/Streber

How do Expert Systems work?

Find most similar case(s).

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

4 / 49

slide-10
SLIDE 10

Motivation: Expert/Legal Systems/Streber

How do Expert Systems work?

Find most similar case(s).

How does the American Justice System work?

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

4 / 49

slide-11
SLIDE 11

Motivation: Expert/Legal Systems/Streber

How do Expert Systems work?

Find most similar case(s).

How does the American Justice System work?

Find most similar case(s).

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

4 / 49

slide-12
SLIDE 12

Motivation: Expert/Legal Systems/Streber

How do Expert Systems work?

Find most similar case(s).

How does the American Justice System work?

Find most similar case(s).

How does the nerd (“Streber”) learn?

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

4 / 49

slide-13
SLIDE 13

Motivation: Expert/Legal Systems/Streber

How do Expert Systems work?

Find most similar case(s).

How does the American Justice System work?

Find most similar case(s).

How does the nerd (“Streber”) learn?

He learns by heart.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

4 / 49

slide-14
SLIDE 14

Eager vs. Lazy Learners

Eager vs. Lazy Learners

Lazy: Save all data from training, use it for classifying (The learner was lazy, classifier has to do the work) Eager: Builds a (compact) model/structure during training, use model for classification. (The learner was eager/worked harder, classifier has a simple life.)

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

5 / 49

slide-15
SLIDE 15

Nearest neighbour predictors

Nearest neighbour predictors are special case of instance-based learning.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

6 / 49

slide-16
SLIDE 16

Nearest neighbour predictors

Nearest neighbour predictors are special case of instance-based learning. Instead of constructing a model that generalizes beyond the training data, the training examples are merely stored.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

6 / 49

slide-17
SLIDE 17

Nearest neighbour predictors

Nearest neighbour predictors are special case of instance-based learning. Instead of constructing a model that generalizes beyond the training data, the training examples are merely stored. Predictions for new cases are derived directly from these stored examples and their (known) classes or target values.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

6 / 49

slide-18
SLIDE 18

Simple nearest neighbour predictor

For a new instance, use the target value of the closest neighbour in the training set. Classification

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

7 / 49

slide-19
SLIDE 19

Simple nearest neighbour predictor

For a new instance, use the target value of the closest neighbour in the training set.

input

  • utput

Classification Regression

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

7 / 49

slide-20
SLIDE 20

Nearest Neighbour Predictor: Issues

Noisy Data is a problem: How can we fix this?

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

8 / 49

slide-21
SLIDE 21

k-nearest neighbour predictor

Instead of relying for the prediction on only one instance, the (single) nearest neighbour, usually the k (k > 1) are taken into account, leading to the k-nearest neighbour predictor.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

9 / 49

slide-22
SLIDE 22

k-nearest neighbour predictor

Instead of relying for the prediction on only one instance, the (single) nearest neighbour, usually the k (k > 1) are taken into account, leading to the k-nearest neighbour predictor. Classification: Choose the majority class among the k nearest neighbours for prediction.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

9 / 49

slide-23
SLIDE 23

k-nearest neighbour predictor

Instead of relying for the prediction on only one instance, the (single) nearest neighbour, usually the k (k > 1) are taken into account, leading to the k-nearest neighbour predictor. Classification: Choose the majority class among the k nearest neighbours for prediction. Regression: Take the mean value of the k nearest neighbours for prediction.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

9 / 49

slide-24
SLIDE 24

k-nearest neighbour predictor

Instead of relying for the prediction on only one instance, the (single) nearest neighbour, usually the k (k > 1) are taken into account, leading to the k-nearest neighbour predictor. Classification: Choose the majority class among the k nearest neighbours for prediction. Regression: Take the mean value of the k nearest neighbours for prediction. Disadvantage:

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

9 / 49

slide-25
SLIDE 25

k-nearest neighbour predictor

Instead of relying for the prediction on only one instance, the (single) nearest neighbour, usually the k (k > 1) are taken into account, leading to the k-nearest neighbour predictor. Classification: Choose the majority class among the k nearest neighbours for prediction. Regression: Take the mean value of the k nearest neighbours for prediction. Disadvantage: All k nearest neighbours have the same influence on the prediction.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

9 / 49

slide-26
SLIDE 26

k-nearest neighbour predictor

Instead of relying for the prediction on only one instance, the (single) nearest neighbour, usually the k (k > 1) are taken into account, leading to the k-nearest neighbour predictor. Classification: Choose the majority class among the k nearest neighbours for prediction. Regression: Take the mean value of the k nearest neighbours for prediction. Disadvantage: All k nearest neighbours have the same influence on the prediction. Closer nearest neighbours should have higher influence on the prediction.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

9 / 49

slide-27
SLIDE 27

Ingredients for the k-nearest neighbour predictor

Distance Metric: The distance metric, together with a possible task-specific scaling or weighting of the attributes, determines which of the training examples are nearest to a query data point and thus selects the training example(s) used to produce a prediction.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

10 / 49

slide-28
SLIDE 28

Ingredients for the k-nearest neighbour predictor

Distance Metric: The distance metric, together with a possible task-specific scaling or weighting of the attributes, determines which of the training examples are nearest to a query data point and thus selects the training example(s) used to produce a prediction. Number of Neighbours: The number of neighbours of the query point that are considered can range from only one (the basic nearest neighbour approach) through a few (like k-nearest neighbour approaches) to, in principle, all data points as an extreme case.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

10 / 49

slide-29
SLIDE 29

Ingredients for the k-nearest neighbour predictor

Distance Metric: The distance metric, together with a possible task-specific scaling or weighting of the attributes, determines which of the training examples are nearest to a query data point and thus selects the training example(s) used to produce a prediction. Number of Neighbours: The number of neighbours of the query point that are considered can range from only one (the basic nearest neighbour approach) through a few (like k-nearest neighbour approaches) to, in principle, all data points as an extreme case (would that be a good idea?).

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

10 / 49

slide-30
SLIDE 30

Ingredients for the k-nearest neighbour predictor

weighting function for the neighbours Weighting function defined on the distance of a neighbour from the query point, which yields higher values for smaller distances.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

11 / 49

slide-31
SLIDE 31

Ingredients for the k-nearest neighbour predictor

weighting function for the neighbours Weighting function defined on the distance of a neighbour from the query point, which yields higher values for smaller distances. prediction function For multiple neighbours, one needs a procedure to compute the prediction from the (generally differing) classes or target values of these neighbours, since they may differ and thus may not yield a unique prediction directly.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

11 / 49

slide-32
SLIDE 32

k Nearest neighbour predictor

input

  • utput

input

  • utput

Average (3 nearest neighbours) Distance weighted (2 nearest neighbours)

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

12 / 49

slide-33
SLIDE 33

Nearest neighbour predictor

Choosing the “ingredients”

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

13 / 49

slide-34
SLIDE 34

Nearest neighbour predictor

Choosing the “ingredients” distance metric Problem dependent. Often Euclidean distance (after normalisation).

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

13 / 49

slide-35
SLIDE 35

Nearest neighbour predictor

Choosing the “ingredients” distance metric Problem dependent. Often Euclidean distance (after normalisation). number of neighbours Very often chosen on the basis of cross-validation. Choose k that leads to the best performance for cross-validation.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

13 / 49

slide-36
SLIDE 36

Nearest neighbour predictor

Choosing the “ingredients” distance metric Problem dependent. Often Euclidean distance (after normalisation). number of neighbours Very often chosen on the basis of cross-validation. Choose k that leads to the best performance for cross-validation. weighting function for the neighbours E.g. tricubic weighting function: w(si, q, k) =

  • 1 −
  • d(si,q)

dmax(q,k)

  • 3

3

q Query point si (input vector of) the i-th nearest neighbour of q in the training data set k number of considered neighbours d employed distance function dmax(q, k) maximum distance between any two nearest neighbours and the distances of the nearest neighbours to the query point

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

13 / 49

slide-37
SLIDE 37

Nearest neighbour predictor

Choosing the “ingredients” prediction function

Regression: Compute the weighted average of the target values of the nearest neighbours. Classification:

Sum up the weights for each class among the nearest neighbours. Choose the class with the highest value (or incorporate a cost matrix and interpret the summed weights for the classes as likelihoods).

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

14 / 49

slide-38
SLIDE 38

Kernel functions

A k-nearest neighbour predictor with a weighting function can be interpreted as an n-nearest neighbour predictor with a modified weighting function where n is the number of (training) data.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

15 / 49

slide-39
SLIDE 39

Kernel functions

A k-nearest neighbour predictor with a weighting function can be interpreted as an n-nearest neighbour predictor with a modified weighting function where n is the number of (training) data. The modified weighting function simply assigns the weight 0 to all instances that do not belong to the k nearest neighbours.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

15 / 49

slide-40
SLIDE 40

Kernel functions

A k-nearest neighbour predictor with a weighting function can be interpreted as an n-nearest neighbour predictor with a modified weighting function where n is the number of (training) data. The modified weighting function simply assigns the weight 0 to all instances that do not belong to the k nearest neighbours. More general approach: Use a general kernel function that assigns a distance-dependent weight to all instances in the training data set.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

15 / 49

slide-41
SLIDE 41

Kernel functions

Such a kernel function K assigning a weight to each data point that depends on its distance d to the query point should satisfy the following properties:

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

16 / 49

slide-42
SLIDE 42

Kernel functions

Such a kernel function K assigning a weight to each data point that depends on its distance d to the query point should satisfy the following properties: K(d) ≥ 0

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

16 / 49

slide-43
SLIDE 43

Kernel functions

Such a kernel function K assigning a weight to each data point that depends on its distance d to the query point should satisfy the following properties: K(d) ≥ 0 K(0) = 1 (or at least, K has its mode at 0)

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

16 / 49

slide-44
SLIDE 44

Kernel functions

Such a kernel function K assigning a weight to each data point that depends on its distance d to the query point should satisfy the following properties: K(d) ≥ 0 K(0) = 1 (or at least, K has its mode at 0) K(d) decreases monotonously with increasing d.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

16 / 49

slide-45
SLIDE 45

Kernel functions

Typical examples for kernel functions (σ > 0 is a predefined constant): Krect(d) = 1 if d ≤ σ,

  • therwise

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

17 / 49

slide-46
SLIDE 46

Kernel functions

Typical examples for kernel functions (σ > 0 is a predefined constant): Krect(d) = 1 if d ≤ σ,

  • therwise

Ktriangle(d) = Krect(d) · (1 − d/σ)

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

17 / 49

slide-47
SLIDE 47

Kernel functions

Typical examples for kernel functions (σ > 0 is a predefined constant): Krect(d) = 1 if d ≤ σ,

  • therwise

Ktriangle(d) = Krect(d) · (1 − d/σ) Ktricubic(d) = Krect(d) · (1 − d3/σ3)3

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

17 / 49

slide-48
SLIDE 48

Kernel functions

Typical examples for kernel functions (σ > 0 is a predefined constant): Krect(d) = 1 if d ≤ σ,

  • therwise

Ktriangle(d) = Krect(d) · (1 − d/σ) Ktricubic(d) = Krect(d) · (1 − d3/σ3)3 Kgauss(d) = exp

  • − d2

2σ2

  • Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011.

c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

17 / 49

slide-49
SLIDE 49

Locally weighted (polynomial) regression

For regression problems: So far, weighted averaging of the target values. Instead of a simple weighted average, one can also compute a (local) regression function at the query point taking the weights into account.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

18 / 49

slide-50
SLIDE 50

Locally weighted polynomial regression

input

  • utput

input

  • utput

Kernel weighted regression (left) vs. distance-weighted 4-nearest neighbour regression (tricubic weighting function, right) in one dimension.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

19 / 49

slide-51
SLIDE 51

Adjusting the distance function

The choice of the distance function is crucial for the success of a nearest neighbour approach.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

20 / 49

slide-52
SLIDE 52

Adjusting the distance function

The choice of the distance function is crucial for the success of a nearest neighbour approach. One can try do adapt the distance function.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

20 / 49

slide-53
SLIDE 53

Adjusting the distance function

The choice of the distance function is crucial for the success of a nearest neighbour approach. One can try do adapt the distance function. One way to adapt the distance function is feature weights to put a stronger emphasis on those feature that are more important.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

20 / 49

slide-54
SLIDE 54

Adjusting the distance function

The choice of the distance function is crucial for the success of a nearest neighbour approach. One can try do adapt the distance function. One way to adapt the distance function is feature weights to put a stronger emphasis on those feature that are more important. A configuration of feature weights can be evaluated based on cross-validation.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

20 / 49

slide-55
SLIDE 55

Adjusting the distance function

The choice of the distance function is crucial for the success of a nearest neighbour approach. One can try do adapt the distance function. One way to adapt the distance function is feature weights to put a stronger emphasis on those feature that are more important. A configuration of feature weights can be evaluated based on cross-validation. The optimisation of the feature weights can then be carried out based

  • n some heuristic strategy like hill climbing, simulated annealing,

evolutionary algorithms.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

20 / 49

slide-56
SLIDE 56

Data set reduction, prototype building

Advantage of the nearest neighbour approach: No time for training is needed – at least when no feature weight adaptation is carried out or the number of nearest neighbours is fixed in advance.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

21 / 49

slide-57
SLIDE 57

Data set reduction, prototype building

Advantage of the nearest neighbour approach: No time for training is needed – at least when no feature weight adaptation is carried out or the number of nearest neighbours is fixed in advance. Disadvantage: Calculation of the predicted class or value can take long when the data set is large.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

21 / 49

slide-58
SLIDE 58

Data set reduction, prototype building

Advantage of the nearest neighbour approach: No time for training is needed – at least when no feature weight adaptation is carried out or the number of nearest neighbours is fixed in advance. Disadvantage: Calculation of the predicted class or value can take long when the data set is large. Possible solutions:

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

21 / 49

slide-59
SLIDE 59

Data set reduction, prototype building

Advantage of the nearest neighbour approach: No time for training is needed – at least when no feature weight adaptation is carried out or the number of nearest neighbours is fixed in advance. Disadvantage: Calculation of the predicted class or value can take long when the data set is large. Possible solutions: Finding a smaller subset of the training set for the nearest neighbour predictor.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

21 / 49

slide-60
SLIDE 60

Data set reduction, prototype building

Advantage of the nearest neighbour approach: No time for training is needed – at least when no feature weight adaptation is carried out or the number of nearest neighbours is fixed in advance. Disadvantage: Calculation of the predicted class or value can take long when the data set is large. Possible solutions: Finding a smaller subset of the training set for the nearest neighbour predictor. Building prototypes by merging (close) instances, for instance by averaging.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

21 / 49

slide-61
SLIDE 61

Data set reduction, prototype building

Advantage of the nearest neighbour approach: No time for training is needed – at least when no feature weight adaptation is carried out or the number of nearest neighbours is fixed in advance. Disadvantage: Calculation of the predicted class or value can take long when the data set is large. Possible solutions: Finding a smaller subset of the training set for the nearest neighbour predictor. Building prototypes by merging (close) instances, for instance by averaging. Can be carried out based on cross-validation and using heuristic

  • ptimisation strategies.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

21 / 49

slide-62
SLIDE 62

Choice of parameter k

Linear classification problem (with some noise):

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

22 / 49

slide-63
SLIDE 63

Choice of parameter k

1 nearest neighbour:

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

23 / 49

slide-64
SLIDE 64

Choice of parameter k

2 nearest neighbour:

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

24 / 49

slide-65
SLIDE 65

Choice of parameter k

5 nearest neighbour:

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

25 / 49

slide-66
SLIDE 66

Choice of parameter k

50 nearest neighbour:

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

26 / 49

slide-67
SLIDE 67

Choice of parameter k

470 nearest neighbour:

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

27 / 49

slide-68
SLIDE 68

Choice of parameter k

480 nearest neighbour:

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

28 / 49

slide-69
SLIDE 69

Choice of parameter k

500 nearest neighbour:

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

29 / 49

slide-70
SLIDE 70

Choice of Parameter k

k=1 yields y=piecewise constant labeling ”too small” k: very sensitive to outliers ”too large” k: many objects from other clusters (classes) in the decision set k = N predicts y=globally constant (majority) label The selection of k depends from various input ”parameters” : the size n of the data set the quality of the data ...

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

30 / 49

slide-71
SLIDE 71

Choice of Parameter k: cont.

Simple classifier, k = 1, 2, . . .

Concept, Images, and Analysis from Peter Flach.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

31 / 49

slide-72
SLIDE 72

Choice of Parameter k: cont.

Simple data

Concept, Images, and Analysis from Peter Flach.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

32 / 49

slide-73
SLIDE 73

Choice of Parameter k: cont.

Simple classifier, k = 1. Voronoi Tesselation of input space.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

33 / 49

slide-74
SLIDE 74

Choice of Parameter k: cont.

Simple classifier, k = 1. ...and classification.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

34 / 49

slide-75
SLIDE 75

Choice of Parameter k: cont.

Simple classifier, k = 1

Concept, Images, and Analysis from Peter Flach.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

35 / 49

slide-76
SLIDE 76

Choice of Parameter k: cont.

Simple classifier, k = 2

Concept, Images, and Analysis from Peter Flach.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

36 / 49

slide-77
SLIDE 77

Choice of Parameter k: cont.

Simple classifier, k = 2

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

37 / 49

slide-78
SLIDE 78

Choice of Parameter k: cont.

Simple classifier, k = 3

Concept, Images, and Analysis from Peter Flach.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

38 / 49

slide-79
SLIDE 79

Choice of Parameter k

k = 1: highly localized classifier, perfectly fits separable training data k > 1:

the instance space partition refines more segments are labelled with the same local models

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

39 / 49

slide-80
SLIDE 80

Choice of Parameter k - Cross Validation

k is mostly determined manual or heuristic One heuristic : Cross Validation

1 Select a cross validation method (e.g. q-fold cross validation with

D = D1

.

∪ ...

.

∪ Dq)

2 Select a range for k (e.g. 1 < k <= kmax) 3 Select an evaluation measure (e.g.

E(k) = q

i=1

  • x∈Di p(x is correct classified|D \ Di))

4 Use k which results in minimal kbest = arg min (E(k))

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

40 / 49

slide-81
SLIDE 81

Choice of Parameter k - Cross Validation

k is mostly determined manual or heuristic One heuristic : Cross Validation

1 Select a cross validation method (e.g. q-fold cross validation with

D = D1

.

∪ ...

.

∪ Dq)

2 Select a range for k (e.g. 1 < k <= kmax) 3 Select an evaluation measure (e.g.

E(k) = q

i=1

  • x∈Di p(x is correct classified|D \ Di))

4 Use k which results in minimal kbest = arg min (E(k))

Can we do this in KNIME?...

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

40 / 49

slide-82
SLIDE 82

kNN Classifier: Summary

Instance Based Classifier: Remembers all training cases Sensitive to neighborhood:

Distance Function Neighborhood Weighting Prediction (Aggregation) Function

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

41 / 49

slide-83
SLIDE 83

Food for Thought: 1-NN Classifier

Bias of the Learning Algorithm? Model Bias? Hypothesis Space?

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

42 / 49

slide-84
SLIDE 84

Food for Thought: 1-NN Classifier

Bias of the Learning Algorithm?

No variations in search: simple store all examples

Model Bias? Hypothesis Space?

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

42 / 49

slide-85
SLIDE 85

Food for Thought: 1-NN Classifier

Bias of the Learning Algorithm?

No variations in search: simple store all examples

Model Bias?

Classification via Nearest Neighbor

Hypothesis Space?

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

42 / 49

slide-86
SLIDE 86

Food for Thought: 1-NN Classifier

Bias of the Learning Algorithm?

No variations in search: simple store all examples

Model Bias?

Classification via Nearest Neighbor

Hypothesis Space?

One hypothesis only: Voronoi partitioning of space

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

42 / 49

slide-87
SLIDE 87

Again: Lazy vs. Eager Learners

kNN learns a local model at query time

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

43 / 49

slide-88
SLIDE 88

Again: Lazy vs. Eager Learners

kNN learns a local model at query time Previous algorithms (k-means, ID3, ...) learn a global model before query time.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

43 / 49

slide-89
SLIDE 89

Again: Lazy vs. Eager Learners

kNN learns a local model at query time Previous algorithms (k-means, ID3, ...) learn a global model before query time. Lazy Algorithms:

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

43 / 49

slide-90
SLIDE 90

Again: Lazy vs. Eager Learners

kNN learns a local model at query time Previous algorithms (k-means, ID3, ...) learn a global model before query time. Lazy Algorithms:

do nothing during training (just store examples)

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

43 / 49

slide-91
SLIDE 91

Again: Lazy vs. Eager Learners

kNN learns a local model at query time Previous algorithms (k-means, ID3, ...) learn a global model before query time. Lazy Algorithms:

do nothing during training (just store examples) Generate new hypothesis for each query (“class A!” in case of kNN!)

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

43 / 49

slide-92
SLIDE 92

Again: Lazy vs. Eager Learners

kNN learns a local model at query time Previous algorithms (k-means, ID3, ...) learn a global model before query time. Lazy Algorithms:

do nothing during training (just store examples) Generate new hypothesis for each query (“class A!” in case of kNN!)

Eager Algorithms:

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

43 / 49

slide-93
SLIDE 93

Again: Lazy vs. Eager Learners

kNN learns a local model at query time Previous algorithms (k-means, ID3, ...) learn a global model before query time. Lazy Algorithms:

do nothing during training (just store examples) Generate new hypothesis for each query (“class A!” in case of kNN!)

Eager Algorithms:

do as much as possible during training (ideally: extract the one relevant rule!)

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

43 / 49

slide-94
SLIDE 94

Again: Lazy vs. Eager Learners

kNN learns a local model at query time Previous algorithms (k-means, ID3, ...) learn a global model before query time. Lazy Algorithms:

do nothing during training (just store examples) Generate new hypothesis for each query (“class A!” in case of kNN!)

Eager Algorithms:

do as much as possible during training (ideally: extract the one relevant rule!) Generate one global hypothesis (or a set, see Candidate-Elimination)

  • nce.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

43 / 49

slide-95
SLIDE 95

Other Types of Lazy Learners

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

44 / 49

slide-96
SLIDE 96

Lazy Decision Trees

Can we use a Decision Tree Algorthm in a lazy mode?

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

45 / 49

slide-97
SLIDE 97

Lazy Decision Trees

Can we use a Decision Tree Algorthm in a lazy mode? Sure: only create branch that contains test case.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

45 / 49

slide-98
SLIDE 98

Lazy Decision Trees

Can we use a Decision Tree Algorthm in a lazy mode? Sure: only create branch that contains test case. Better: do beam search instead of greedy “branch” building!

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

45 / 49

slide-99
SLIDE 99

Lazy Decision Trees

Can we use a Decision Tree Algorthm in a lazy mode? Sure: only create branch that contains test case. Better: do beam search instead of greedy “branch” building! Works for essentially all model building algorithms (but makes sense for “partitioning”-style algorithms only...

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

45 / 49

slide-100
SLIDE 100

Lazy(?) Neural Networks

Specht introduced Probabilistic Neural Networks in 1990.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

46 / 49

slide-101
SLIDE 101

Lazy(?) Neural Networks

Specht introduced Probabilistic Neural Networks in 1990. Special type of Neural Networks, optimized for classification tasks.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

46 / 49

slide-102
SLIDE 102

Lazy(?) Neural Networks

Specht introduced Probabilistic Neural Networks in 1990. Special type of Neural Networks, optimized for classification tasks. One Neuron per training instance

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

46 / 49

slide-103
SLIDE 103

Lazy(?) Neural Networks

Specht introduced Probabilistic Neural Networks in 1990. Special type of Neural Networks, optimized for classification tasks. One Neuron per training instance Actually long known as “Parzen Window Classifier” in statistics.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

46 / 49

slide-104
SLIDE 104

Lazy(?) Neural Networks

Specht introduced Probabilistic Neural Networks in 1990. Special type of Neural Networks, optimized for classification tasks. One Neuron per training instance Actually long known as “Parzen Window Classifier” in statistics.

Parzen Window

The Parzen windows method is a non-parametric procedure that synthesizes an estimate of a probability density function (pdf) by superposition of a number of windows, replicas of a function (often the Gaussian).

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

46 / 49

slide-105
SLIDE 105

Probabilistic Neural Networks

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

47 / 49

slide-106
SLIDE 106

Probabilistic Neural Networks

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

48 / 49

slide-107
SLIDE 107

Probabilistic Neural Networks

Probabilistic Neural Networks are powerful predictors (but σ-adjustment problematic)

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

49 / 49

slide-108
SLIDE 108

Probabilistic Neural Networks

Probabilistic Neural Networks are powerful predictors (but σ-adjustment problematic) Efficient (and eager!) training algorithms exist that introduce more general neurons, covering more than just one training instance.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

49 / 49

slide-109
SLIDE 109

Probabilistic Neural Networks

Probabilistic Neural Networks are powerful predictors (but σ-adjustment problematic) Efficient (and eager!) training algorithms exist that introduce more general neurons, covering more than just one training instance. Usual problems of distance based classifiers apply.

Compendium slides for “Guide to Intelligent Data Analysis”, Springer 2011. c Michael R. Berthold, Christian Borgelt, Frank H¨

  • ppner, Frank Klawonn and Iris Ad¨

a

49 / 49