Skip to content

Can i use weka from python

There are several ways of using Weka in Python or Python-like environment.


If you're starting from scratch, you might want to consider Jython, a rewrite of Python to seamlessly integrate with Java. The drawback is, that you can only use the libraries that Jython implements, not others like NumPy or SciPy. The article Using WEKA from Jython explains how to use WEKA classes from Jython and how to implement a new classifier in Jython, with an example of ZeroR implemented in Jython.


An approach making use of the javax.script package (new in Java 6) is Jepp, Java embedded Python. Jepp seems to have the same limitations as Jython, not being able to import Scipy or Numpy, but one can import pure Python libraries. The arcticle Using WEKA via Jepp contains more information and examples.


Another solution, to access Java from within Python applications is JPype.


You can use the python-weka-wrapper3 Python 3 library to access most of the non-GUI functionality of Weka (3.9.x):


With the sklearn-weka-plugin library, you can use Weka from within the scikit-learn framework. The library itself uses python-weka-wrapper3 under the hood to make use of the Weka algorithms.