Filter löschen
Filter löschen

LibSVM data preparation problem

1 Ansicht (letzte 30 Tage)
Matija
Matija am 16 Jan. 2012
Kommentiert: med djo am 11 Jan. 2017
Hello all,
I just started to work with LibSVM and have a problem:
I have all the data I want to work with (image features), but dont know how to make LibSVM data file.
When using libsvmwrite to transfer for example Matlab matrix into LibSVM data file, I get "Instance_matrix must be sparse" error.
Thank you in advance, Matija.
  2 Kommentare
Walter Roberson
Walter Roberson am 16 Jan. 2012
Any matrix can be converted to a sparse matrix using the sparse() call.
med djo
med djo am 11 Jan. 2017
Assuming that you have three different classes (1,2,3). The first class contains two samples, the second contain one, the third contain one. From each class, you will extract two values (Average and median) of the color (for example). It will give you that: classe 1: (15, 20) classe 1: (16, 21) classe 2: ( 18, 22) classe 3: (22, 24) . On matlab, we make a matrix (Matrix for learning), which contains two columns, four lines and which contain (15, 20; 16, 21;18, 22; 22, 24). And we made a matrix composed of a single column (label matrix), this matrix (1, 1, 2, 3). We execute learning SVM with SVMtrain from libSVM. The parameters I have given you as an example correspond to the RBF kernel. The gamma value, c (varies between 10 and 100,000). Please, can you help me to execute this scenario in Matlab using LibSVM??

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Matija
Matija am 16 Jan. 2012
OK, part of the answer is in the LibSVM FAQ:
Q: How to convert other data formats to LIBSVM format?
with example attached.
Data we are importing must be in CSV (comma-separated values) file format.
  1 Kommentar
med djo
med djo am 11 Jan. 2017
Assuming that you have three different classes (1,2,3). The first class contains two samples, the second contain one, the third contain one. From each class, you will extract two values (Average and median) of the color (for example). It will give you that: classe 1: (15, 20) classe 1: (16, 21) classe 2: ( 18, 22) classe 3: (22, 24) . On matlab, we make a matrix (Matrix for learning), which contains two columns, four lines and which contain (15, 20; 16, 21;18, 22; 22, 24). And we made a matrix composed of a single column (label matrix), this matrix (1, 1, 2, 3). We execute learning SVM with SVMtrain from libSVM. The parameters I have given you as an example correspond to the RBF kernel. The gamma value, c (varies between 10 and 100,000). Please, can you help me to execute this scenario in Matlab using LibSVM??

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Statistics and Machine Learning Toolbox finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by