How to input train data and test data (features of images) using SVM calssifier
Afficher commentaires plus anciens
This is the code that i have got for classification using SVM. Can any one tell me how should i input train data and test data in the code,...
% Classfication using SVM classifier.............
% 1. Load the sample data
load dataname
% 2. Create data, a two-column matrix containing sepal length and sepal width % measurements for 150 irises.
data = [meas(:,1), meas(:,2)];
% 3. From the species vector, create a new column vector, groups, to classify data % into two groups: data and non-data.
groups = ismember(dataset,'data');
% 4. Randomly select training and test sets.
[train, test] = crossvalind('holdOut',groups); cp = classperf(groups);
% 5. Train an SVM classifier using a linear kernel function and plot the grouped data.
svmStruct = svmtrain(data(train,:),groups(train),'showplot',true);
% 6. Add a title to the plot, using the KernelFunction field from the svmStruct % structure as the title.
title(sprintf('Kernel Function: %s',... func2str(svmStruct.KernelFunction)),... 'interpreter','none');
% 7. Use the svmclassify function to classify the test set.
classes = svmclassify(svmStruct,data(test,:),'showplot',true);
% 8. Evaluate the performance of the classifier.
classperf(cp,classes,test); cp.CorrectRate
% ans =
% 0.9867
% 9. Use a one-norm, hard margin support vector machine classifier by changing the
% boxconstraint property.
figure svmStruct = svmtrain(data(train,:),groups(train),... 'showplot',true,'boxconstraint',1e6);
classes = svmclassify(svmStruct,data(test,:),'showplot',true);
% 10. Evaluate the performance of the classifier.
classperf(cp,classes,test); cp.CorrectRate
%ans =
% 0.9867
2 commentaires
Fadi Alsuhimat
le 5 Juin 2020
did you solve it?
sabiya fatima
le 29 Juil 2020
i am getting error in line 4:
Undefined function 'crossvalind' for input
arguments of type 'char'.
please help to solve it
Réponses (1)
Haddouche Abdelouahab
le 21 Mar 2017
0 votes
I would like to help with my project represented in classification EEG using lda pca ica and svm
9 commentaires
Anggerik aida
le 18 Avr 2017
can u help me..i need a guide to build the svm claassifier?
Salma Hassan
le 22 Juil 2017
me too sir i want a code to help me plz
suganya sri
le 11 Nov 2017
i too want code to help for my project sir
salima smiti
le 28 Jan 2018
me too sir I need the code please help me
Ramya k
le 22 Mar 2020
sir i am also need code for this svm steps
sabiya fatima
le 29 Juil 2020
Sir can you please send me the code
Sara Rabei
le 30 Août 2020
Can i have it too!?.. Thank you
Sara Rabei
le 30 Août 2020
Can i have it too!?.. Thank you
Sara Rabei
le 30 Août 2020
Sorry for duplicating my messages..
Catégories
En savoir plus sur Discriminant Analysis dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!