Skip to main content

Vowpal Wabbit Python package

Project description

ImageLink

Vowpal Wabbit is a fast machine learning library for online learning, and this is the python wrapper for the project.

Installing this package builds Vowpal Wabbit locally for explicit use within python, it will not create the command-line version of the tool (or affect any previously existing command-line installations). To install the command-line version see the main project page: https://github.com/VowpalWabbit/vowpal_wabbit

The version of the PyPI vowpalwabbit package corresponds to the tagged version of the code in the github repo that will be used during building and installation. If you need to make local changes to the code and rebuild the python binding be sure to pip uninstall vowpalwabbit then rebuild using the local repo installation instructions below.

Installation

See the installation instructions

Usage

You can use the python wrapper directly like this:

>>> import vowpalwabbit
>>> vw = vowpalwabbit.Workspace(quiet=True)
>>> ex = vw.example('1 | a b c')
>>> vw.learn(ex)
>>> vw.predict(ex)

Or you can use the included scikit-learn interface like this:

>>> import numpy as np
>>> from sklearn import datasets
>>> from sklearn.model_selection import train_test_split
>>> from vowpalwabbit.sklearn import VWClassifier
>>>
>>> # generate some data
>>> X, y = datasets.make_hastie_10_2(n_samples=10000, random_state=1)
>>> X = X.astype(np.float32)
>>>
>>> # split train and test set
>>> X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=256)
>>>
>>> # build model
>>> model = VWClassifier()
>>> model.fit(X_train, y_train)
>>>
>>> # predict model
>>> y_pred = model.predict(X_test)
>>>
>>> # evaluate model
>>> model.score(X_train, y_train)
>>> model.score(X_test, y_test)

Troubleshooting

See the troubleshooting guide

Development

Contributions are welcome for improving the python wrapper to Vowpal Wabbit.

  1. Check for open issues or create one to discuss a feature idea or bug.

  2. Fork the repo on Github and make changes to the master branch (or a new branch off of master).

  3. Write a test in the python/tests folder showing the bug was fixed or feature works (recommend using pytest).

  4. Make sure package installs and tests pass under all supported environments (this calls tox automatically).

  5. Send the pull request.

Tests can be run using setup.py:

$ python setup.py test

Directory Structure:

  • python : this is where the c++ extension lives

  • python/vowpalwabbit : this is then main directory for python wrapper code and utilities

  • python/examples : example python code and jupyter notebooks to demonstrate functionality

  • python/tests : contains all tests for python code

Note: neither examples nor tests directories are included in the distributed package, they are only for development purposes.

Project details


Download files

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

Source Distribution

vowpalwabbit-9.10.0.tar.gz (33.3 MB view hashes)

Uploaded Source

Built Distributions

vowpalwabbit-9.10.0-cp310-cp310-win_amd64.whl (4.0 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

vowpalwabbit-9.10.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.3 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

vowpalwabbit-9.10.0-cp310-cp310-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (3.4 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.12+ x86-64

vowpalwabbit-9.10.0-cp310-cp310-macosx_11_0_arm64.whl (2.7 MB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

vowpalwabbit-9.10.0-cp310-cp310-macosx_10_9_x86_64.whl (2.9 MB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

vowpalwabbit-9.10.0-cp39-cp39-win_amd64.whl (4.1 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

vowpalwabbit-9.10.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.3 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

vowpalwabbit-9.10.0-cp39-cp39-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (3.4 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

vowpalwabbit-9.10.0-cp39-cp39-macosx_11_0_arm64.whl (2.7 MB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

vowpalwabbit-9.10.0-cp39-cp39-macosx_10_9_x86_64.whl (2.9 MB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

vowpalwabbit-9.10.0-cp38-cp38-win_amd64.whl (4.0 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

vowpalwabbit-9.10.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.3 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

vowpalwabbit-9.10.0-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (3.4 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

vowpalwabbit-9.10.0-cp38-cp38-macosx_11_0_arm64.whl (2.7 MB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

vowpalwabbit-9.10.0-cp38-cp38-macosx_10_9_x86_64.whl (2.9 MB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

vowpalwabbit-9.10.0-cp37-cp37m-win_amd64.whl (3.8 MB view hashes)

Uploaded CPython 3.7m Windows x86-64

vowpalwabbit-9.10.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.3 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

vowpalwabbit-9.10.0-cp37-cp37m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (3.4 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

vowpalwabbit-9.10.0-cp37-cp37m-macosx_10_9_x86_64.whl (2.9 MB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

vowpalwabbit-9.10.0-cp36-cp36m-win_amd64.whl (3.8 MB view hashes)

Uploaded CPython 3.6m Windows x86-64

vowpalwabbit-9.10.0-cp36-cp36m-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (3.4 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.12+ x86-64

vowpalwabbit-9.10.0-cp36-cp36m-macosx_10_9_x86_64.whl (2.9 MB view hashes)

Uploaded CPython 3.6m macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page