本文介绍了如何使用分类器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在数据功能上使用svm,knn,adaboost分类器.我建立代码,在其中计算帧差并计算特征(特征值,应变能,势能能量....建立起[帧数,特征]的数组.我尝试将svm用作:

I want to use the svm, knn, adaboost classifier on my data features. I build up code where I calculated the frame differences and calculated the features (eigenvalues, strain energy, potential energy).... build up an array of [number of frames , features]. I try to use svm as:

 Features = data;  % Features array [40, 5]
 class = ones(numFrames-1, 1);  % numFrames=41
 class(1:(fix(numFrames/2))) = -1;
 SVMstruct = svmtrain(Features, class, 'Kernel_Function', 'rbf');
 newclass = svmclassify(SVMstruct, [40 5]);  %Test data

我遇到一个错误:

%classperf(cp,newclass); cp'`

%classperf(cp,newclass); %performance of the class given by cp'`

此错误的原因是什么?以及如何使用具有此功能集的其他分类器?

What is the reason for this error? And how do I to use further classifiers with this features set?

推荐答案

我可以从收到的错误中推断出以下情况.

I can infer following things from the error which you are getting.

svmtrain中没有错误,表示size(features)=[40 5].错误在最后一行.请参见svmclassify的语法.您传递的测试数据样本的特征/列数与案例5中的训练数据相同.相反,您传递的大小为[40 5],只有两列.通过n行和5列的实际测试集.最后一行应该是

There is no error in svmtrain that means size(features)=[40 5]. The error is in the last line. See the syntax of svmclassify. You pass a sample of test data which has same number of features/columns as the training data in your case 5). Instead you are passing the size which is [40 5] which has only two columns. Pass the actual test set of n rows and 5 columns. The last line should be

newclass= svmclassify(SVMstruct,testData); %where size(testData)=[n 5], n indicates how many test samples you have.

这篇关于如何使用分类器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 03:51