Last active
October 14, 2016 13:10
-
-
Save rysk-t/9d7c771c4aa9d778a59a16a0595d7bc5 to your computer and use it in GitHub Desktop.
MatlabでlibSVM (&libnlinear) を導入,fisher data に適用する ref: http://qiita.com/rysk-t/items/a0281ed80db999575dd3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> addpath(genpath('path¥to¥libsvm')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> cd('path¥to¥libsvm¥matlab') | |
>> make |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> mex -setup | |
エラー: mex | |
サポートされているコンパイラまたは SDK が見つかりません。オプションについては、 | |
http://www.mathworks.com/support/compilers/R2015a/maci64.html を参照してください。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
load('fisheriris.mat') | |
labels = unique(species); | |
specIdx = zeros(150,1); | |
for i = 1:length(labels) | |
specIdx(find(strcmp(species, labels{i})))=i; % クラスを数字にする | |
end | |
randsort = randperm(150); | |
test = randsort(1:15); % テストデータのインデックス | |
trn = randsort(16:end); % 学習データのインデックス | |
% - test 5 featuress | |
% for i = 5:100 | |
% meas(:,i) = meas(:,1)+randn(150,1); | |
% end | |
testDS = meas(test, :); | |
trnDS = meas(trn, :); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model_svm = svmtrain(specIdx(trn), trnDS, '-t 0') | |
svmpredict(specIdx(test), testDS, model_svm); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment