error using svmtrain (not enough inputs)

i am using a code
clc
C=[1 2 3 ;4 5 6]
TrainLabel=C;TrainVec=[0;1];
bestcv = 0;
for log2c = -6:10,
for log2g = -6:3,
cmd = ['-v 5 -c ', num2str(2^log2c), ' -g ', num2str(2^log2g)];
cv = svmtrain(TrainLabel,TrainVec, cmd);
if (cv >= bestcv),
bestcv = cv; bestc = 2^log2c; bestg = 2^log2g;
end
fprintf('(best c=%g, g=%g, rate=%g)\n',bestc, bestg, bestcv);
end
end
i get error as
Error using ==> svmtrain at 225
Incorrect number of arguments to svmtrain.
Error in ==> ex2011 at 10
cv = svmtrain(TrainLabel,TrainVec, cmd);
please help were i have done mistake

답변 (3개)

Ilya
Ilya 2012년 4월 5일

0 개 추천

If you are using svmtrain function from the official MATLAB install (verify by typing 'which svmtrain' in your command window), it does not accept the syntax of your cmd string. Please read 'help svmtrain' or 'doc svmtrain'.
Walter Roberson
Walter Roberson 2012년 4월 5일

0 개 추천

The Mathworks-provided svmtrain() does not accept an argument which is a single string with flags and values. Instead it accepts only name/value pairs, such as
svmtrain(TrainLabel,TrainVec, 'method', 'SMO')
The flags you use have no obvious correspondence in the supported name/value pairs.

댓글 수: 3

kash
kash 2012년 4월 6일
But walter i want to apply those values of c and gamma,i want to use rbf kernel,is what i had performed correct?
kash
kash 2012년 4월 6일
i got those codings from one of websites only

댓글을 달려면 로그인하십시오.

ansha nisar
ansha nisar 2021년 8월 12일

0 개 추천

How can I resolve this problem Error using svmtrain

댓글 수: 1

models{k} = fitcsvm(Trainfea, G1vAll, 'solver', 'SMO');
and later
if predict(models{k}, Testfea(j,:))

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

태그

질문:

2012년 4월 5일

댓글:

2021년 8월 12일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by