MLCC - Laboratory 1 - Local methods


This lab is about local methods for binary classification on synthetic data. The goal of the lab is to get familiar with the kNN algorithm and to get a practical grasp of what we have discussed in class. Follow the instructions below. Think hard before you call the instructors!

Download:

1. Warm up - data generation

Open the matlab file MixGauss.m

[X, Y] = MixGauss([[0;0],[1;1]],[0.5,0.25],50);
figure(1); title('dataset 1');
scatter(X(:,1),X(:,2),50,Y,'filled'); %type "help scatter" to see what the parameters mean
title('dataset 1');

2. Core - kNN classifier

The k-Nearest Neighbors algorithm (kNN) assigns to a test point the most frequent label among its k closest points/examples in the training set.

figure;
scatter(Xte(:,1),Xte(:,2),50,Yte,'filled'); %plot test points (filled circles) associating a different color to each "true" label
hold on
scatter(Xte(:,1),Xte(:,2),70,Ypred,'o'); % plot test points (empty circles) associating a different color to each estimated label

3. Parameter selection - What is a good value for k?

So far we considered an arbitrary k. We now want to inroduce different approaches for selecting it.

4. If you have time - More experiments