필터 지우기
필터 지우기

How to use W vector in adaboost SVM?

조회 수: 1 (최근 30일)
Fateme Jalali
Fateme Jalali 2016년 8월 20일
댓글: Image Analyst 2016년 8월 20일
Hello,I wrote this code for multiclass classification using svm and adaboost. I do not know how to use W vector for libsvm option (cmd). because W in cmd must be a number, not a vector.can any one help me plz? Thanks.
N = length(X); % X training labels
W = 1/N * ones(N,1); %Weights initialization
M = 10; % Number of boosting iterations
for m=1:M
C = 10; %The cost parameters of the linear SVM, you can...
perform a grid search for the optimal value as well
%Calculate the error and alpha in adaBoost with cross validation
cmd = ['-c ', num2str(C), ' -w ', num2str(W)];
model = svmtrain(X, Y, cmd);
[Xout, acc, ~] = svmpredict(X,Y,cmd);
err = sum(.5 * W .* acc * N)/sum(W);
alpha = log( (1-err)/err );
% update the weight
W = W.*exp( - alpha.*Xout.*X );
W = W/norm(W);
end
  댓글 수: 1
Image Analyst
Image Analyst 2016년 8월 20일
You might want to include your X and Y so people can run your code.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Classification에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by