我是Matlab的新手。是否有示例代碼用SVM分類某些數據(具有41個功能),然後將結果可視化?我想使用SVM方法對數據集(它有五個類)進行分類。 我閱讀了「A Practical Guide to Support Vector Classication」文章,並看到了一些示例。我的數據集是kdd99。我寫了下面的代碼:如何在Matlab中使用SVM?
%% Load Data
[data,colNames] = xlsread('TarainingDataset.xls');
groups = ismember(colNames(:,42),'normal.');
TrainInputs = data;
TrainTargets = groups;
%% Design SVM
C = 100;
svmstruct = svmtrain(TrainInputs,TrainTargets,...
'boxconstraint',C,...
'kernel_function','rbf',...
'rbf_sigma',0.5,...
'showplot','false');
%% Test SVM
[dataTset,colNamesTest] = xlsread('TestDataset.xls');
TestInputs = dataTset;
groups = ismember(colNamesTest(:,42),'normal.');
TestOutputs = svmclassify(svmstruct,TestInputs,'showplot','false');
,但我不知道怎麼去準確性或我的分類MSE,我在我的svmclassify
使用showplot
但true
的時候,我得到這樣的警告:
The display option can only plot 2D training data
任何人都可以幫我嗎?
你需要更多地瞭解機器學習的一般情況,它不是一個好的或簡單的盲目使用工具。 –
我同意@ Raff.Edward,但你應該看到的是交叉驗證來衡量你的錯誤/準確性。 –