分享

How to add LibSVM class to WEKA classpath on a Mac

 oskycar 2014-12-04

Q : 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 running Max OS X 10.7 Lion.

Files in LibSVM download that need to be added to classpath

I am attempting to use the LibSVM classifier in WEKA because it is preferable for me over SMO. I am receiving the following error and cannot figure out how to add this to the classpath on a Mac. 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.

Error I am receiving in WEKA

         4 Answers


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
answered Feb 14 '12 at 11:43
chl
10.4k32252
    
Thanks! I will try this out this evening (and mark this as the accepted answer if it works). Thanks again, –  maj nem ?z d?n Feb 14 '12 at 16:28
    
@DanO'Day Did you have a chance to try the above. Did that work? –  chl Feb 26 '12 at 20:31
    
I apologize for not getting back to this. Yes, this worked great! Thanks, –  maj nem ?z d?n Feb 26 '12 at 21:54
    
Coming back to this over a year later and I have no idea how to make it work. Any simpler instructions out there? –  maj nem ?z d?n Apr 19 '13 at 4:53

Here is another extremely easy way to add LibSVM support to WEKA on OS X (no command line needed):

  1. Download LibSVM from here
  2. Go to /Applications folder on your Mac (the folder where the Weka app is installed)
  3. Right click on Weka > Chose "Show Package Contents"
  4. Copy libsvm.jar to /Applications/Weka.app/Contents/Resources/Java
  5. open /Applications/Weka.app/Contents/Info.plist in your favorite text editor
  6. change <string>$JAVAROOT/weka.jar</string> to <string>$JAVAROOT/weka.jar:$JAVAROOT/libsvm.jar</string> (you can also adjust the heap size here)
  7. Save and start weka
answered Oct 9 '13 at 11:54
Daniel Gerber
424412
    
Thank you for solving but I have a problem is including this one "evaluating classifier rand". How can I handle it? –  endeR Dec 1 '13 at 23:31

Download the libsvm files and past them in the working directory of weka. Now goes to Control Panel->System->Advance System Setting-> and Edit the Environment Variable, Select the Class_Path variable and copy all that path along with the file name. i.e. C:\Program Files\Weka\Libsvm.jar; and click ok-ok-ok and Restart the weka

answered Jan 24 at 14:44
zaheer
91

1) Copy libsvm.jar found here into the Java folder in the package content of the weka.app, path-to-the-Weka.app/Contents/Java/

2) Add this line to your .bash_profile or similar configuration file

export CLASSPATH="path-to-the-Weka.app/Contents/Java/weka.jar:path-to-the-Weka.app/Contents/Java/libsvm.jar"

Note: you should replace path-to-the-Weka.app by your own path. It could look like /Applications/JavaApp/weka-3-6-11-oracle-jvm.app

answered Nov 22 at 19:15

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.      

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多