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')
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 setup a local Python virtual environment for testing, run:
./init_virtualenv.sh
To run all tests:
export TESTNAME=; tox
To run tests for a specific environment (e.g. Python 3.9):
export TESTNAME=; tox -e py39
To run a specific test:
export TESTNAME=.test_IBk; tox -e py39
Metadata
Release files for weka 2.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| weka-2.0.2.tar.gz | 80.2 kB | Without provenance | Details for weka-2.0.2.tar.gz |
Release files / weka-2.0.2.tar.gz
| Download URL | weka-2.0.2.tar.gz |
|---|---|
| Size | 80.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
41bcd7cc08654cdc1c596693c28857e6045f9155e8ef5a949ae40b24e74a2ea1
|
|
BLAKE2b-256 checksum How to use checksums |
74d3183343580dff8852f90f76a716c5c657c2bda298f06bff2a9cf0b9ed6958
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Security for weka 2.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.