- in both loops, you are assigning the labelData the same value.
- you don't really need those loops: labelData(1:1000) = 0; labelData(1001:2000) = 1;
SVM classifier on digits dataset
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
I have to use SVM classifier on digits dataset. The dataset consists of images of digits 28x28 and a toal of 2000 images.
I tried to use svmtrain but the matlab gave an error that svmtrain has been removed. so now i am using fitcsvm.
My code is as below:
labelData = zeros(2000,1);
for i=1:1000
labelData(i,1)=1;
end
for j=1001:2000
labelData(j,1)=1;
end
SVMStruct =fitcsvm(trainingData,labelData)
%where training data is the set of images of digits.
I need to know how i can predict the outputs of test data using svm? Further is my code correct?
0 comentarios
Respuestas (1)
Ridwan Alam
el 14 de Dic. de 2019
Editada: Ridwan Alam
el 14 de Dic. de 2019
fitcsvm() is not designed to train directly on 28x28 images. You need to extract feature vectors for each image. After feature extraction, you will have a dataset with size 2000xN, where N is the number of features for each image. Let's say X is this new extracted feature set of size 2000xN, and Y is your labeledData of size 2000x1.
Now, before training fitcsvm(), you need to use cvpartition() (or something similar, maybe your custom method) to divide both the features and the labels data into training and testing dataset. Then, you can use
SVMStruct =fitcsvm(trainingData,trainingLabelData)
As far as I know, you can use Convolutional Neural Networks (CNN) to train directly on images.
Minor issues with your code:
Hope this helps.
0 comentarios
Ver también
Categorías
Más información sobre Image Data Workflows en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!