weka中使用Liblinear

来源:互联网 发布:ubuntu16 更换软件源 编辑:程序博客网 时间:2024/06/05 09:50

LINUX

1. 下载和解压weka。下载:wget http://prdownloads.sourceforge.net/weka/weka-3-7-9.zip。解压weka到该当前目录:unzip weka-3-6-10.zip


2. 配置环境变量。
gedit~/.bashrc
export  WEKAROOT=/home/cming/weka-3-7-9
export  CLASSPATH=$CLASSPATH:$WEKAROOT/weka.jar
Source~/.bashrc


3. 运行WEKA,运行命令:cd $WEKAROOT
运行命令:java -Xmx1000M-jar weka.jar




4.通过weka packagesmanager下载liblinear,先安装WEKA3.7.9,用tools-packagemanager安装liblinear,然后到用户目录wekafiles\packages\LibLINEAR下中找到liblinear.jar在 wekafiles\packages\LibLINEAR\lib下找到liblinear-1.51-with-deps.jar,并将这两个jar放到WEKA-3-7-9的安装目录下。

5.  运行命令:

java -Xmx1024m -cpweka.jar:LibLINEAR.jar:liblinear-1.51-with-deps.jarweka.classifiers.functions.LibLINEAR -S 0 -C 1 -B -1 -t Source.arff -T Target.arff–i


WIN7

1.   环境变量

假设我们的weka.jar的目录在C:/ProgramFiles/Weka-3-6/weka.jar,其中,C:/ProgramFiles/Weka-3-6是weka安装目录。在系统环境变量中添加WEKAROOT:


如果系统环境变量中已经有CLASSPATH,那么,在CLASSPATH后面添加上%WEKAROOT%/weka.jar。如果还没有CLASSPATH,那么,新建一个即可。
运行命令:
java -Xmx1024m -cpweka.jar;LibLINEAR.jar;liblinear-1.51-with-deps.jarweka.classifiers.functions.LibLINEAR -S 0 -C 1 -B -1 -t Source.arff -T Target.arff–i



解决Liblinear not in CLASSPARH, on linux with weka

That's because the liblinear.jar you downloadedis not the original one. The creator of that jar uses his own packagestructure, his classes are placed in
de.bwaldvoge.liblinear
but the standard weka classifier looks for Linear in
liblinear
Onthe bottom of bwaldvogels website that you linked, he gives a link to a Weka wrapper that points to his package.
The Weka package manager isavailable from version 3.7.2 or later, so you have to download the developerversion, since the latest stable is 3.6.9.
Then, simply start the Weka package manager and install LibLINEAR.It worked for me this way. Note, that this will create a "wekafiles"directory in $HOME.



0 1
原创粉丝点击