Matlab预测功能不起作用 [英] Matlab predict function not working
问题描述
我正在尝试在具有100个维度的数据上训练线性SVM.我有80个实例需要培训.我在MATLAB中使用fitcsvm
函数训练SVM,并在训练数据上使用predict
检查该函数.当我使用SVM对训练数据进行分类时,所有数据点仅被分类为一类.
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);
这给出了全0的输出,对应于第0类. b
包含1和0,指示每个数据点所属的类.
所使用的数据(即矩阵votes
和向量b
)具有以下
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
推荐答案
确保使用非线性内核,例如高斯内核,并且已调整内核的参数.只是一个起点:
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
这篇关于Matlab预测功能不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!