I am running Max OS X 10.7 Lion and I want to use WEKA with LibSVM from command line. I get this error:
Problem evaluating classifier: libsvm classes not in CLASSPATH!
I found the LibSVM library here. I need to add it to my Java classpath so that WEKA can find it. The download contains several files, shown below. I don't know how to add them to my classpath for Java.
I am attempting to use the LibSVM classifier in WEKA because it is preferable for me over SMO. I am also unsure if this means the Java classpath or if it is specific to WEKA. I also don't know where to get these classes from. Any help is appreciated.
Here is another extremely easy way to add LibSVM support to WEKA on OS X (no command line needed):
<string>$JAVAROOT/weka.jar</string>
to <string>$JAVAROOT/weka.jar:$JAVAROOT/libsvm.jar</string>
(you can also adjust the heap size here)You can put libsvm.jar
in a folder of your choice, e.g. ~/Library/Java
, and then run weka from the command-line as follows:
$ java -Xmx512m -classpath /Users/chl/weka/weka.jar:/Library/Java/libsvm.jar weka.gui.GUIChooser
You can also update your CLASSPATH
to reflect locations where *.jar
files can be found. I have the following in my .profile
:
export CLASSPATH="/Users/chl/weka/weka.jar:~/Library/Java/*"
(You will need to replace /Users/chl/weka
to reflect the correct location of your weka.jar
; usually, it is located at the top of the directory if you downloaded the source files, or under weka-3-7-3.app/Contents/Resources/Java/
if you use the bundled app.)
This way, the first command to start weka GUI simplifies to
$ java -classpath $CLASSPATH:weka.jar:libsvm.jar weka.gui.GUIChooser
Don't use java -jar
since it will override the CLASSPATH
, as discussed here.
I also have an alias in my .bash_aliases
for wrapping all that stuff:
alias weka='java -Xmx512m -classpath $CLASSPATH:weka.jar'
in order to use weka from the command-line as, e.g.
$ weka weka.classifiers.trees.RandomTree -t iris.arff -i
1) Copy libsvm.jar
found here into the Java folder in the package content of the Weka.app:
<path-to-Weka.app>/Weka.app/Contents/Java/
2) Add this line to your .bash_profile or similar configuration file:
export CLASSPATH="<path-to-Weka.app>/Weka.app/Contents/Java/weka.jar:<path-to-Weka.app>/Weka.app/Contents/Java/libsvm.jar"
Note: you should replace <path-to-Weka.app>
by your own path. It could look like /Applications/JavaApp/weka-3-6-11-oracle-jvm.app
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With