I’ve just recently started using libsvm. I’ve been trying for awhile to train my features get the model and then do a prediction with corresponding features. Unforunately I contiously get wrong file format. I’ve routinely done this measure cut my features and then train on them, which I get a model.
This is how I train to get the model.
I’m doing this via unix command line btw.
./svm-train -t 0 -b 1 svmtrainModel1Revised.txt TrainedModel1.svm
0 1:8.109121 2:11.063075 3:9.265099 4:7.392232 5:9.577386
0 1:7.497237 2:10.314889 3:9.330452 4:8.658748 5:9.493017
0 1:7.579283 2:9.853208 3:9.863712 4:8.48306 5:9.84812
1 1:7.683603 2:10.323639 3:10.616027 4:7.039438 5:10.321418
1 1:7.645213 2:9.742212 3:9.957533 4:8.810831 5:8.86067
0 1:7.738999 2:9.956453 3:9.643299 4:8.553764 5:9.824224
1 1:7.968907 2:10.610946 3:9.061123 4:7.84069 5:9.793263
The model I get from above I predict based on that.
./svm-predict -b 1 svmtest1RevisedA.txt TrainedModel1.svm labelmodel1.txt
These features are in the same format as above, except they are lacking the ground truth.
8.139867 10.146595 9.554127 8.409128 9.380923
7.691873 9.820682 9.777709 9.136581 9.038513
8.629565 10.684548 9.192018 9.031779 9.733009
7.796154 10.871736 9.113837 7.329961 10.071653
7.235544 9.994834 10.601161 8.720384 10.112152
8.008006 10.75276 10.755063 7.517268 9.415618
7.857692 9.936756 9.556366 8.941176 8.933603
7.806821 9.934397 9.324827 8.422852 8.797105
There are no commas and there is only a space between each element,but when i got to predict it tells me Wrong input format at line 1. please help.
You need to make the training labels either 1 or -1. This is standard within the SVM sub-world of the machine learning world. Also you might want to take out any tabs and make sure your whitespace only consists of spaces.
Here are a few lines from a file I trained with using libsvm:
If you’re still confused about the input format, use the script checkdata.py. It’s located in the
libsvm-3.12/toolsdirectory (relative to your libsvm installation) and can explain errors in formatting if any exist.