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