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 did this measure cut my features and then train on them, which i get a model.
This is how I train to get the model.
./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.
2 answers
I haven't used libsvm much, but your models seems to be missing the header. This is what I get when I run the svm-train command (same software version, package for ArchLinux):
svm_type c_svc
kernel_type linear
nr_class 2
total_sv 6
rho 2.76767
label 0 1
probA 1.12362
probB -1.22234
nr_sv 3 3
SV
1 1:8.109121 2:11.063075 3:9.265099 4:7.392232 5:9.577386
1 1:7.579283 2:9.853208 3:9.863712 4:8.48306 5:9.84812
1 1:7.738999 2:9.956453 3:9.643299 4:8.553764 5:9.824224
-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
-1 1:7.968907 2:10.610946 3:9.061123 4:7.84069 5:9.793263
Make sure that your file didn't get corrupted andMake sure that your file didn't get corrupted and you don't get any errors when training your data. Another reason might be that the libsvm package of your distribution is broken.
Your set containing the instances to be predicted needs to be in exactly the same format as the training data. This means it needs a leading (dummy) class label (set it to 1) per instance, and the feature values per instance have to be preceded by a running number that reflects the feature number plus colon.
Log in to answer this question.