Adding jar files to weka

Recently, I had to implement a machine learning algorithm called MLRules. I found the code on the author's webpage but there was a big problem. It was in Java using the WEKA environment. I had never worked in the Java before. Above that, I had another alien named 'weka'. Initially everything seemed out of the world. I tried different things, searched on google, read wiki after wiki but there doesn't seem to be a working solution of adding new classifiers in form of .jar files to run in weka.

My search on google began with query 'adding jar files to weka'. I searched and searched till the query became 'cannot add jar file to weka'. I was nearly ending an unsuccessful pursuit of the 'WEKA' when one of the results came up from the 'google code' site about adding thier code to weka. The steps were well documented. I tried working it out and ALAS!!! it started working. It took a week's time just to do a simple thing. I ran the code and it took less than 7 secs to complete. At that point, I thought of writing this post.

I have tried it on both Windows and Linux(Ubuntu 8.10).

Lets see on Linux first.

The first thing needed is to set the CLASSPATH:
export CLASSPATH=$CLASSPATH:/home/vipul/Desktop/weka-3-5-8/weka.jar:/usr/lib/jvm/java-6-sun-1.6.0.10/jre/:/home/vipul/Desktop/weka-3-5-8/mlrules.jar
I added JRE path as my CLASSPATH was empty and weka was giving errors about not finding the JDBC drivers. But that didn't help and I am still having the problem.

Run from terminal:
java weka.gui.GenericPropertiesCreator weka/gui/GenericPropertiesCreator.props $HOME/GenericObjectEditor.props
This will generate a file GenericObjectEditor.props in the home directory. This is needed to show the classifier in the weka explorer.

Now you need to edit this file:
http://weka.wiki.sourceforge.net/GenericObjectEditor+(developer+version) will help you understand the basics.
Just find the line starting with
weka.classifiers.Classifier=
and add the class path. In my case it was
weka.classifiers.rules.MLRules

Run the program from your weka directory:
java -cp $CLASSPATH -Xmx500m weka.gui.explorer.Explorer

THATS IT!!!!!! Happy Classification

In case of Windows, I just set the Environment Variable CLASSPATH to also have the path of mlrules.jar.

You extract the “GenericObjectEditor.props” file from weka.jar (jar files are in fact ordinary zip archives, the GenericObjectEditor.props is under /weka/gui).

Place the file you've just extracted into the directory where you have installed Weka (on Windows this is commonly "C:\Program Files\Weka-3-5")

Find the

#
Lists the Classifiers I want to choose from

heading and scroll far down to the end of the block (first empty line), then add a line:

weka.classifiers.rules.MLRules

Do not forget to append a comma and a backslash to the previous line.


Comments

Rahul Agrawal said…
Nicely written introduction about WEKA. I am usually playing around with various machine learning algorithms and found WEKA to be quite useful. I too suffered from the handicap of not knowing Java, so this post helped a lot. Thanks
paxtonjach said…
micro titanium trim to fit the back of the T2 - ATITOMICART
‎Tort tube supplier and T2TiTi · joico titanium ‎Tort and T2Ti · joico titanium ‎Tort and titanium bar stock T2TiTi titanium forging

Popular posts from this blog

EMR master instance is not reachable

Compiz Desktop Effects Keyboard Shortcuts