Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A Python wrapper for Weka
Python
Branch: master

Merge pull request #2 from hakantkn/patch-1

Required changes for running in Windows.
latest commit 3174cd3bcb
@chrisspen authored
Failed to load latest commit information.
weka For running in Windows
.gitignore Updated ignore.
LICENSE Initial commit.
README.md Updated docs.
setup.py Fixed file descriptor memory leak.

README.md

Weka - Python wrapper for Weka classifiers

Overview

Provides a convenient wrapper for calling Weka classifiers from Python.

Installation

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 weka

Usage

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

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

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

from weka.classifiers import IBk
c = IBk(K=1)
c.train('training.arff')
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:

c.save('myclassifier.pkl')
c = Classifier.load('myclassifier.pkl')
predictions = c.predict('query.arff')
Something went wrong with that request. Please try again.