Search code examples
wekalibsvm

LibSVM using Weka command line


I am trying to use LibSVM from weka command line but it gives me error: Error: Could not find or load main class weka.classifiers.functions.LibSVM I tried java -cp weka.jar:LibSVM.jar:"C:\wekafiles\packages\LibSVM\LibSVM.jar":"\wekafiles\packages\LibSVM\lib\libsvm.jar" weka.classifiers.functions.LibSVM -S 0 -K 1 -D 3 -G 0.0 -R 0.0 -N 0.5 -M 40.0 -C 1.0 -E 0.001 -P 0.1 -model D:\Weka-3-8-5 -seed 1 Other ML algorithms works but the one I installed using weka are not working from command line.


Solution

  • Since you installed LibSVM as a Weka package, you should run it using the weka.Run class instead of assembling the classpath manually:

    java -cp weka.jar weka.Run .LibSVM -S 0 -K 1 -D 3 -G 0.0 -R 0.0 -N 0.5 -M 40.0 -C 1.0 -E 0.001 -P 0.1 -model D:\Weka-3-8-5 -seed 1
    

    Of course, you still need to supply other parameters to this command-line, like training and/or test data.

    The added benefit of using weka.Run, you don't need to supply the full classname of the classifier either (as long as there is no other class with that name).