0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 load cltrain;
0011 fit = locfit([x1 x2],y,'family','binomial','scale',0);
0012 lfplot(fit,'contour');
0013 hold on;
0014 u = find(y==0);
0015 plot(x1(u),x2(u),'.');
0016 u = find(y==1);
0017 plot(x1(u),x2(u),'.','color','red');
0018 hold off;
0019
0020 py = fitted(fit)>0.5;
0021 disp('Classification table for training data');
0022 tabulate(10*y+py);
0023
0024 load cltest;
0025 py = predict(fit,[x1 x2])>0;
0026 disp('Classification table for test data');
0027 tabulate(10*y+py);