Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

A Python wrapper for the Weka data mining library.

Project description

Weka - Python wrapper for Weka classifiers


Provides a convenient wrapper for calling Weka classifiers from Python.


First install the Weka and LibSVM Java libraries. On Debian/Ubuntu this is simply:

sudo apt-get install weka libsvm-java

Then install the Python package with pip:

sudo pip install pywekaclassifiers


Train and test a Weka classifier by instantiating the Classifier class, passing in the name of the classifier you want to use:

from pywekaclassifiers.classifiers import Classifier
c = Classifier(name='weka.classifiers.lazy.IBk', ckargs={'-K':1})
predictions = c.predict('query.arff')

Alternatively, you can instantiate the classifier by calling its name directly:

from pywekaclassifiers.classifiers import IBk
c = IBk(K=1)
predictions = c.predict('query.arff')

The instance contains Weka's serialized model, so the classifier can be easily pickled and unpickled like any normal Python instance:'myclassifier.pkl')
c = Classifier.load('myclassifier.pkl')
predictions = c.predict('query.arff')


Tests require the Python development headers to be installed, which you can install on Ubuntu with:

sudo apt-get install python-dev python3-dev python3.4-dev

To run unittests across multiple Python versions, install:

sudo apt-get install python3.4-minimal python3.4-dev python3.5-minimal python3.5-dev

To run all tests:

export TESTNAME=; tox

To run tests for a specific environment (e.g. Python 2.7):

export TESTNAME=; tox -e py27

To run a specific test:

export TESTNAME=.test_IBk; tox -e py27

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pywekaclassifiers, version 0.0.3
Filename, size File type Python version Upload date Hashes
Filename, size pywekaclassifiers-0.0.3-py3-none-any.whl (81.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size pywekaclassifiers-0.0.3.tar.gz (483.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page