Contents
clc; close all; clear all;
load citiesBig1
[n,d] = size(X);
[t,d] = size(Xtest);
K Nearest Neighbour
model = knn(X,y,3);
yhat1 = model.predict(model,X);
errTraining = sum(yhat1 ~= y)/n
yhat2 = model.predict(model,Xtest);
errTest = sum(yhat2 ~= ytest)/t
size(model.X)
classifier2Dplot1(X,y,Xtest,ytest,model);
errTraining =
0.003868340685443
errTest =
0.012147947064812
ans =
14735 2
Condensed Nearest Neighbour
model = cnn(X,y,3);
yhat1 = model.predict(model,X);
errTraining = sum(yhat1 ~= y)/n
yhat2 = model.predict(model,Xtest);
errTest = sum(yhat2 ~= ytest)/t
size(model.X)
classifier2Dplot1(X,y,Xtest,ytest,model);
errTraining =
0.007533084492704
errTest =
0.017577197149644
ans =
457 2