davidsoergel / jlibsvm

Efficient training of Support Vector Machines in Java
Other
117 stars 62 forks source link

Error while reading model file #9

Open yannisKork opened 10 years ago

yannisKork commented 10 years ago

Hi developers,

I am trying to run jlibsvm using the legacyexec programs svm_train and svm_predict. I have successfully run svm_train and produced a model file. Then, I provided this model file as the second attribute of svm_predict, but I get the following error.

Exception in thread "main" edu.berkeley.compbio.jlibsvm.SvmException: Unable to load file models/a2a.m at edu.berkeley.compbio.jlibsvm.SolutionModel.identifyTypeAndLoad(SolutionModel.java:69) at svm_predict.main(svm_predict.java:47) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at edu.berkeley.compbio.jlibsvm.SolutionModel.identifyTypeAndLoad(SolutionModel.java:59) ... 1 more Caused by: java.lang.NullPointerException at java.util.StringTokenizer.(StringTokenizer.java:199) at java.util.StringTokenizer.(StringTokenizer.java:236) at edu.berkeley.compbio.jlibsvm.binary.BinaryModel.(BinaryModel.java:133) ... 6 more

I think the problem lies in BinaryModel. I have tried versions 0.91 and 0.92, but I get the same error. I have also inspected the model file that is produced by svm_train and it seems perfectly logical.

Thanks in advance for your reply! Yannis

yannisKork commented 10 years ago

It seems that the model file produced by svm_train is not entirely correct:

svm_type c_svc RBF gamma=0.008403361774981022label rho -0.62833524 total_sv 754 nr_class 2 SV 1.0 3:1.0 10:1.0 17:1.0 20:1.0 37:1.0 40:1.0 48:1.0 63:1.0 67:1.0 73:1.0 74:1.0 77:1.0 80:1.0 83:1.0 1.0 5:1.0 7:1.0 17:1.0 22:1.0 36:1.0 40:1.0 56:1.0 63:1.0 67:1.0 73:1.0 74:1.0 76:1.0 80:1.0 83:1.0 .... ....

I have figured out that a line defining the label property is missing. Adding "label 0 1" or "label whatever" in the head of the file solves the problem. Can you say why svm_train did not produce the model file correctly? I used as arguments "sets/a1a models/a1a.m" where a1a is the file downloaded from: http://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/binary.html

Independently of the string following "label", in svm_predict.java, prediction is either true or false, while target is either 1.0 or -1.0. Can you suggest how prediction and target can be aligned?

Thanks again, Yannis

gdouchufu commented 10 years ago

sorry,your ‍mail send to the wrong person...‍

------------------ 原始邮件 ------------------ 发件人: "yannisKork";notifications@github.com; 发送时间: 2014年9月8日(星期一) 凌晨5:29 收件人: "davidsoergel/jlibsvm"jlibsvm@noreply.github.com;

主题: Re: [jlibsvm] Error while reading model file (#9)

It seems that the model file produced by svm_train is not entirely correct:

svm_type c_svc RBF gamma=0.008403361774981022label rho -0.62833524 total_sv 754 nr_class 2 SV 1.0 3:1.0 10:1.0 17:1.0 20:1.0 37:1.0 40:1.0 48:1.0 63:1.0 67:1.0 73:1.0 74:1.0 77:1.0 80:1.0 83:1.0 1.0 5:1.0 7:1.0 17:1.0 22:1.0 36:1.0 40:1.0 56:1.0 63:1.0 67:1.0 73:1.0 74:1.0 76:1.0 80:1.0 83:1.0 .... ....

I have figured out that a line defining the label property is missing. Adding "label 0 1" or "label whatever" in the head of the file solves the problem. Can you say why svm_train did not produce the model file correctly? I used as arguments "sets/a1a models/a1a.m" where a1a is the file downloaded from: http://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/binary.html

Independently of the string following "label", in svm_predict.java, prediction is either true or false, while target is either 1.0 or -1.0. Can you suggest how prediction and target can be aligned?

Thanks again, Yannis

— Reply to this email directly or view it on GitHub.