2009年9月7日月曜日

AND演算(AND operation)でSVM(Support Vector Machine)で解いてみる

%----------------- MATLABソース -----------------%
% AND演算でSVM(サポートベクターマシン)で解いてみる
X=[0 0; 0 1; 1 0; 1 1; ];
G=[0; 0; 0; 1;];
% クロスバリデーションインデックスの生成
[train, test] = crossvalind('holdOut',G);
cp = classperf(G);
% サポートベクトルマシーンクラスタリングの学習
svmStruct = svmtrain(X(train,:),G(train),'Kernel_Function','polynomial', 'showplot',true,'Method','LS');
%svmStruct = svmtrain(X(train,:), G(train), 'showplot', true, 'Kernel_Function', 'polynomial', 'Polyorder', 3);
%r=svmtrain(train_set,%train_response,'Kernel_Function','rbf','showplot','true');
%svmStruct = svmtrain(X(train,:), G(train), 'showplot', true, 'Kernel_Function', 'quadratic');

% サポートベクトルマシーンを利用したクラスタリング
classes = svmclassify(svmStruct,X(test,:),'showplot',true);
grid on
% クラスタリングのパフォーマンスを計算
classperf(cp,classes,test);
% 正答率を表示する
cp.CorrectRate
%----------------- MATLABソース -----------------%

0 件のコメント: