matlab - Query for SVM classifier : svmtrain function -
i want use svmstruct = svmtrain(training,group)
2 classes (noraml , abnormal) images classification purpose,and size of training matrix 1*40 cells
,and each cell 75 rows * 10 columns
want give training matrix svmtrain
function after calling svmtrain
function got error :
error using svmtrain (line 241) training must numeric matrix
could guide how correct error, because stuck in error, thank you.
the following code lines tried :
clc clear all; close all; %% after creating them in section of code section loading 2 training matrices load('norglobal_matrix_train_variablek10bin25md.mat') load('abglobal_matrix_train_variablek10bin25md.mat') counter_im=1; [row ,col]=size(norglobal_matrix_train_variablek10bin25md); i=1:10:row temp=norglobal_matrix_train_variablek10bin25md(i:i+9,1:end); trasposed_temp=temp'; normal_features {counter_im} =trasposed_temp; traininglabel{counter_im}=1 ; counter_im=counter_im+1; end svm=svmtrain(normal_features{:}, traininglabel{:});
this old code written svm may you
%# split training/testing sets [trainidx testidx] = crossvalind('holdout', lbls, 1/2); % split train , test labels 50%-50% pairwise = nchoosek(1:size(gn, 1), 2); %# 1-vs-1 pairwise models svmmodel = cell(size(pairwise, 1), 1); %# store binary-classifers predtest = zeros(sum(testidx), numel(svmmodel)); %# store binary predictions %# classify using one-against-one approach, svm 3rd degree poly kernel k=1:numel(svmmodel) %# training instances belonging pair idx = trainidx & any( bsxfun(@eq, g, pairwise(k,:)) , 2 ); %# train % svmmodel{k} = svmtrain(dataset(idx,:), g(idx), ... % 'boxconstraint',2e-1, 'kernel_function','polynomial', 'polyorder',3); svmmodel{k} = svmtrain(dataset(idx,:), g(idx), ... 'boxconstraint', inf, 'kernel_function', 'rbf', 'rbf_sigma', 14.51); %# test predtest(:,k) = svmclassify(svmmodel{k}, dataset(testidx,:)); % matlab native svm function end pred = mode(predtest, 2); %# voting: clasify class receiving votes %# performance cmat = confusionmat(g(testidx), pred); %# g(testidx) == targets, pred == outputs final_acc = 100*sum(diag(cmat))./sum(cmat(:)); fprintf('svm (1-against-1):\naccuracy = %.2f%%\n', final_acc); fprintf('confusion matrix:\n'), disp(cmat) % assignin('base', 'cmatrix', cmat);
that content based image retrieval project can search on , find many code link url
http://www.mathworks.com/matlabcentral/fileexchange/42008-content-based-image-retrieval
Comments
Post a Comment