Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Instance Based Learning Ata Kaban The University of Birmingham.

Similar presentations


Presentation on theme: "1 Instance Based Learning Ata Kaban The University of Birmingham."— Presentation transcript:

1 1 Instance Based Learning Ata Kaban The University of Birmingham

2 2 Today we learn: n K-Nearest Neighbours n Locally weighted regression n Case-based reasoning n Lazy and eager learning

3 3 Instance-based learning n One way of solving tasks of approximating discrete or real valued target functions n Have training examples: (x n, f(x n )), n=1..N. n Key idea: –just store the training examples –when a test example is given then find the closest matches

4 4 n 1-Nearest neighbour: Given a query instance x q, first locate the nearest training example x n then f(x q ):= f(x n ) n K-Nearest neighbour: Given a query instance x q, first locate the k nearest training examples if discrete values target function then take vote among its k nearest nbrs else if real valued target fct then take the mean of the f values of the k nearest nbrs

5 5 The distance between examples n We need a measure of distance in order to know who are the neighbours n Assume that we have T attributes for the learning problem. Then one example point x has elements x t  , t=1,…T. The distance between two points x i x j is often defined as the Euclidean distance:

6 6 Voronoi Diagram

7 7 Characteristics of Inst-b-Learning n An instance-based learner is a lazy-learner and does all the work when the test example is presented. This is opposed to so-called eager-learners, which build a parameterised compact model of the target. It produces local approximation to the target function (different with each test instance)

8 8 When to consider Nearest Neighbour algorithms? n Instances map to points in n Not more then say 20 attributes per instance n Lots of training data n Advantages: –Training is very fast –Can learn complex target functions –Don’t lose information n Disadvantages: –? (will see them shortly…)

9 9 two one four three five six seven Eight ?

10 10 Training data Test instance

11 11 Keep data in normalised form One way to normalise the data a r (x) to a´ r (x) is

12 12 Normalised training data Test instance

13 13 Distances of test instance from training data Classification 1-NNYes 3-NNYes 5-NNNo 7-NNNo

14 14 What if the target function is real valued? n The k-nearest neighbour algorithm would just calculate the mean of the k nearest neighbours

15 15 Variant of kNN: Distance-Weighted kNN n We might want to weight nearer neighbors more heavily n Then it makes sense to use all training examples instead of just k (Stepard’s method)

16 16 Difficulties with k-nearest neighbour algorithms n Have to calculate the distance of the test case from all training cases n There may be irrelevant attributes amongst the attributes – curse of dimensionality

17 17 A generalisation: Locally Weighted Regression n Some useful terminology –Regression = approximating a real valued function –Residual error = the error in approximating the target function –Kernel function = the function of distance that is used to determine the weight of each training example, I.e.

18 18 (Locally Weighted Regression) n Note kNN forms local approximations to f for each query point n Why not form an explicit local approximation for regions surrounding the query point, e.g. –Fit a linear function to the k nearest neighbours (or a quadratic, …) e.g. –…

19 19 Case-based reasoning (CBR) n CBR is an advanced instance based learning applied to more complex instance objects n Objects may include complex structural descriptions of cases & adaptation rules n It doesn’t use Euclidean distance measures but can do matching between objects using e.g. semantic nets. n It tries to model human problem-solving –uses past experience (cases) to solve new problems –retains solutions to new problems n CBR is an ongoing area of machine learning research with many applications

20 20 Applications of CBR n Design –landscape, building, mechanical, conceptual design of aircraft sub-systems n Planning –repair schedules n Diagnosis –medical n Adversarial reasoning –legal

21 21 CBR process New Case matching Matched Cases Retrieve Adapt? No Yes Closest Case Suggest solution Retain Learn Revise Reuse Case Base Knowledge and Adaptation rules

22 22 CBR example: Property pricing Test instance

23 23 How rules are generated n Examine cases and look for ones that are almost identical –case 1 and case 2 R1: If recep-rooms changes from 2 to 1 then reduce price by £5,000 –case 3 and case 4 R2: If Type changes from semi to terraced then reduce price by £7,000

24 24 Matching n Comparing test instance –matches(5,1) = 3 –matches(5,2) = 3 –matches(5,3) = 2 –matches(5,4) = 1 n Estimate price of case 5 is £25,000

25 25 Adapting n Reverse rule 2 –if type changes from terraced to semi then increase price by £7,000 n Apply reversed rule 2 –new estimate of price of property 5 is £32,000

26 26 Learning n So far we have a new case and an estimated price –nothing is added yet to the case base n If later we find house sold for £35,000 then the case would be added –could add a new rule if location changes from 8 to 7 increase price by £3,000

27 27 Problems with CBR n How should cases be represented? n How should cases be indexed for fast retrieval? n How can good adaptation heuristics be developed? n When should old cases be removed?

28 28 Advantages n An local approximation is found for each test case n Knowledge is in a form understandable to human beings n Fast to train

29 29 Summary n K-Nearest Neighbour n (Locally weighted regression) n Case-based reasoning n Lazy and eager learning

30 30 Lazy and Eager Learning n Lazy: wait for query before generalizing –k-Nearest Neighbour, Case based reasoning n Eager: generalize before seeing query –Radial Basis Function Networks, ID3, … n Does it matter? –Eager learner must create global approximation –Lazy learner can create many local approximations


Download ppt "1 Instance Based Learning Ata Kaban The University of Birmingham."

Similar presentations


Ads by Google