KNN Practise Exercises

Prepared by Ayo Akinduko

Note: All screen shots are to be included in these exercises.

Exercise 1

Ensure that the parameters are at default settings

• create a  class with green colour by clicking at the top left corner of the work desk and also click on random to create some outliers
• create a  second class with blue colour by clicking at the bottom right corner of the work desk and also click on random to create some outliers
• Test a query example at the centre. (Hint: click on handle test menu, ensure the method is KNN and click at the centre of the work desk. Example screen shot is shown below)

• Classify the test query using different values of K = 3,5,10 and 20. (To change K, Go to Parameter menu, change the Number of Nearest Neighbour, click Handle test Menu and click the point you want to classify i.e. centre of the work desk)
• Does varying the value of K affect the classification and which K gives a better classification?
• Calculate the MAP at the various K. What can you observe?

• Classify the test query using different values for Effective Radius of Interaction = 30,50,100 . (To change Effective Radius of Interaction, Go to Parameter menu, change the Effective Radius of Interaction , click Handle test Menu and click the point you want to classify i.e. centre of the work desk)
• Does varying the effective radius of interaction affect the classification?
• Calculate the MAP at the various radius. What can you observe?

Students are encouraged to repeat exercises using different points on the work desk (query test) and also changing the parameters.

Exercise 2

Ensure that the parameters are at default settings

• create a  class with green colour by clicking at the top left corner of the work desk and also click on random to create some outliers
• create a  second class with blue colour by clicking at the bottom right corner of the work desk and also click on random to create some outliers.

• Under the Parameter menu, set the number of Nearest Neighbour to 1 (i.e. K = 1)
• Test a query example at the centre. (hint: click on handle test  menu, ensure the method is KNN and click at the centre of the work desk). Save the screen shot.
• Draw the MAP (click on Calculate MAP button under the Maps menu) Save the screen shot.
• After saving the screen shot,  click on  Remove map button under Maps menu
• Example screen shots are shown below.

• Under the Parameter menu, set the Number of nearest neighbours to 1 and Number of Nearest neighbours for outliers detection to 3.click on Implement Reduction button
• Test the same query point used in task 1 of Exercise 2. (hint: click on handle test  menu, ensure the method is KNN and click at the centre of the work desk). Save the screen shot.
• Draw the MAP (click on Calculate MAP button under the Maps menu) Save the screen shot.
•  Example screen shots are shown below.

• Compare the result of the two methods (i.e. 1NN and reduction method CNN) what can you observe?
• Using the Maps, and for every outlier on the Map produced by  CNN compare the colour of the outlier with the corresponding colour of the same spot on the Map produced by 1NN. What can you observe?
• Use the CNN method but changed the Number of NN for outlier detection to 1 (this is under parameter Menu). Draw the MAP and compare with 1NN. What can you observe and explain.
• What are absorption points, outliers and what are the advantages of CNN.

Students are encouraged to repeat exercises using different points on the work desk (query test) and also changing the parameters.

Feedback will be appreciated.