Matlab predict function not working

狂风中的少年 提交于 2019-12-13 09:07:36

问题


I am trying to train a linear SVM on a data which has 100 dimensions. I have 80 instances for training. I train the SVM using fitcsvm function in MATLAB and check the function using predict on the training data. When I classify the training data with the SVM all the data points are being classified into only one class.

SVM = fitcsvm(votes,b,'ClassNames',unique(b)');
predict(SVM,votes);

This gives outputs as all 0's which corresponds to 0th class. b contains 1's and 0's indicating the class to which each data point belongs. The data used, i.e. matrix votes and vector b are given the following link


回答1:


Make sure you use a non-linear kernel, such as a gaussian kernel and that the parameters of the kernel are tweaked. Just as a starting point:

SVM = fitcsvm(votes,b,'KernelFunction','RBF', 'KernelScale','auto');
bp = predict(SVM,votes);

that said you should split your set in a training set and a testing set, otherwise you risk overfitting



来源:https://stackoverflow.com/questions/33302142/matlab-predict-function-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!