Tuesday, March 23, 2010

Use LibSVM in WEKA in an Archlinux box

I found both WEKA and libSVM in AUR, however, neither maintainer considered that a user might use them together... It seem we Archie got to work it out ourselves, so here is what I did:

Dowload WEKA tarball from AUR, and Change weka.sh to

#! /bin/sh
# Note: the '-Xmx256m' flag is used to set the maximum memory that the java
# program is allowed. When working with large data sets, this number may need
# to be increased based on how much memory you wish to allow weka to have.
# Specifying command line arguments will override the defaults shown here.
# Example: '-Xmx512m'
DEFAULT_ARGS='-Xms32m -Xmx256m'
if [ $# -gt 0 ]; then
ARGS="$@"
else
ARGS="$DEFAULT_ARGS"
fi
java -classpath
"${CLASSROOT+CLASSROOT:}/usr/share/java/weka/weka.jar:/usr/share/java/libsvm.jar"
weka.gui.GUIChooser $ARGS

Do not forget to change the MD5SUM of weka.sh in PKGBUILD file :) Modify LibSVM PKGBUILD to:

# Contributor: Pierre Gueth
# Modified by: Yuanjie Huang
pkgname=libsvm
pkgver=2.9
pkgrel=2
pkgdesc="A library for Support Vector Machines classification, include
binaries and python bindings."
arch=(x86_64 i686)
url="http://www.csie.ntu.edu.tw/~cjlin/libsvm/"
license=('GPL')
groups=()
depends=()
makedepends=()
optdepends=()
provides=()
conflicts=()
replaces=()
backup=()
options=()
install=
source=("http://www.csie.ntu.edu.tw/~cjlin/cgi-bin/libsvm.cgi?+http://www.csie.ntu.edu.tw/~cjlin/libsvm+tar.gz")
noextract=()
md5sums=('c48109c825d8326d71c8c8564589736d')
build() {
cd "$srcdir/$pkgname-$pkgver"
make || return 1
install -D -m755 svm-train $pkgdir/usr/bin/svm-train
install -D -m755 svm-predict $pkgdir/usr/bin/svm-predict
install -D -m755 svm-scale $pkgdir/usr/bin/svm-scale
install -D -m644 java/libsvm.jar $pkgdir/usr/share/java/libsvm.jar
cd "python"
python setup.py build || return 1
python setup.py install --root $pkgdir
}

Then makepgk and install, have fun.

No comments:

Post a Comment