Clear Filters
Clear Filters

How to change value of weigh in svmtrain

2 views (last 30 days)
Fateme Jalali
Fateme Jalali on 21 Aug 2016
Hello,I am using libsvm for 60 class classification. I dont know how to write a for loop to update weights of svmtrain. can any one give me the idea? I used this code but it has erorr in cmd.
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

Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!