5

I'm trying to use the svm classifier in weka. When I click on the libsvm classifier and try to train a model based on some provided training data, I get the error

libsvm classes not in CLASSPATH.

The weka website has some information on how to fix this but I'm not sure how to execute them.

http://weka.wikispaces.com/LibSVM

I got the libsvm.jar file from the link provided. I'm not sure which file to put it in.

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
Shaayaan Sayed
  • 231
  • 2
  • 5
  • 13

4 Answers4

2

You have to set your classpath variable so it knows where to find that jar on your local machine.

If you are on windows right-click computer->properties->advanced system settings->environment variables and set it under system variables. Chances are you already have a classpath variable; so just add the path of your jar file to the end.

Reference: http://weka.wikispaces.com/CLASSPATH

Rob Cranfill
  • 2,306
  • 1
  • 18
  • 15
jaesanx
  • 195
  • 1
  • 13
1

Adding to Rob's answer: suit your values as below. This is how it is saved for me.

  • Variable Name: CLASSPATH
  • Variable value: C:\Program Files (x86)\Weka-3-6\libsvm-3.20\java\libsvm.jar
Jamal
  • 763
  • 7
  • 22
  • 32
Sheetal Kaul
  • 3,029
  • 2
  • 13
  • 6
0

You just need Libsvm.jar in the class path with latest versions of weka. Just try it like this

WekaPackageManager.loadPackages( false, true, false );
AbstractClassifier classifier = ( AbstractClassifier ) Class.forName(
        "weka.classifiers.functions.LibSVM" ).newInstance();

If you prefer to give options set the options like this

String options = ( "-S 0 -K 0 -D 3 -G 0.0 -R 0.0 -N 0.5 -M 40.0 -C 1.0 -E 0.001 -P 0.1" );
String[] optionsArray = options.split( " " );
classifier.setOptions( optionsArray );

Finally train the classifier

classifier.buildClassifier( train );
Tharindu
  • 310
  • 4
  • 14
0

In your .bash_profile file or in your environment variables you need to append the full path to the libsvm jar file For a .basch_profile file: export CLASSPATH=$CLASSPATH:/FULL_PATH_TO_LIBSVM.jar

roopalgarg
  • 429
  • 1
  • 6
  • 19