Skip to main content

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 pywekaclassifiers

Usage

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})
c.train('training.arff')
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)
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')

Development

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

Release files for pywekaclassifiers 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pywekaclassifiers 0.0.3
File Size Uploaded
pywekaclassifiers-0.0.3.tar.gz 483.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pywekaclassifiers 0.0.3
File Interpreter ABI Platform
pywekaclassifiers-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 564.4 kB

Release files / pywekaclassifiers-0.0.3.tar.gz

Download URL pywekaclassifiers-0.0.3.tar.gz
Size 483.3 kB
Tags Source
SHA-256 checksum
How to use checksums
9149649da1ca8e0f9536af1669d76e16af30150255ae41e9d83e98b05388fce1
BLAKE2b-256 checksum
How to use checksums
0fa9892927d3e2b2b33e7652ffc582475cdc9e4940efb371715fc6d1a383228f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5

Release files / pywekaclassifiers-0.0.3-py3-none-any.whl

Download URL pywekaclassifiers-0.0.3-py3-none-any.whl
Size 81.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1b2a3f694b32ca6c439dfd5ef73ceb4e955b07575217de14563f0498c98beb8b
BLAKE2b-256 checksum
How to use checksums
fa262e72a9db4033927e295e1f1266139aff731fc10d6df18cb8a1159a15676d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.5

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page