1. 程式人生 > >最簡單的貝葉斯分類器演示(含Matlab程式)

最簡單的貝葉斯分類器演示(含Matlab程式)


plot(x(1,1:N/2),x(2,1:N/2),'rs');
hold on;
plot(x(1,1+N/2:N),x(2,1+N/2:N),'go');
title('2d testing data');
hold on;

%% gaussian model as a baseline
[err,h] = FindModelError(model_pos,model_neg,x,y);
fprintf('Baysian error on test data set: %f\n',err/N);
x_pos = x(:,h==1);
x_neg = x(:,h~=1);
plot(x_pos(1,:),x_pos(2,:),'r.');
hold on;
plot(x_neg(1,:),x_neg(2,:),'g.');
legend('Positve samples','Negative samples','Positve samples as predicted','Negative samples as predicted','Location','SouthEast');