Skip to main content

Convert trained traditional machine learning models into tensor computations

Project description

Introduction

Hummingbird is a library for compiling trained traditional ML models into tensor computations. Hummingbird allows users to seamlessly leverage neural network frameworks (such as PyTorch) to accelerate traditional ML models. Thanks to Hummingbird, users can benefit from: (1) all the current and future optimizations implemented in neural network frameworks; (2) native hardware acceleration; (3) having a unique platform to support for both traditional and neural network models; and have all of this (4) without having to re-engineer their models.

Currently, you can use Hummingbird to convert your trained traditional ML models into PyTorch, TorchScript, and ONNX. Hummingbird supports a variety of ML models and featurizers. These models include scikit-learn Decision Trees and Random Forest, and also LightGBM and XGBoost Classifiers/Regressors. Support for other neural network backends (e.g., TVM) and models is on our roadmap.

Hummingbird also provides a convenient uniform "inference" API following the Sklearn API. This allows swapping Sklearn models with Hummingbird-generated ones without having to change the inference code.

Installation

Hummingbird was tested on Python >= 3.5 on Linux, Windows and MacOS machines. It is recommended to use a virtual environment (See: python3 venv doc or Using Python environments in VS Code.)

Hummingbird requires PyTorch >= 1.4.0. Please go here for instructions on how to install PyTorch based on your platform and hardware.

Once PyTorch is installed, you can get Hummingbird from pip with:

pip install hummingbird-ml

If you require the optional dependencies lightgbm and xgboost, you can use:

pip install hummingbird-ml[extra]

See also Troubleshooting for common problems.

Examples

See the notebooks section for examples that demonstrate use and speedups.

In general, Hummingbird syntax is very intuitive and minimal. To run your traditional ML model on DNN frameworks, you only need to import hummingbird.ml and add convert(model, 'dnn_framework') to your code. Below is an example using a scikit-learn random forest model and PyTorch as target framework.

import numpy as np
from sklearn.ensemble import RandomForestClassifier
from hummingbird.ml import convert

# Create some random data for binary classification
num_classes = 2
X = np.random.rand(100000, 28)
y = np.random.randint(num_classes, size=100000)

# Create and train a model (scikit-learn RandomForestClassifier in this case)
skl_model = RandomForestClassifier(n_estimators=10, max_depth=10)
skl_model.fit(X, y)

# Use Hummingbird to convert the model to PyTorch
model = convert(skl_model, 'pytorch')

# Run predictions on CPU
model.predict(X)

# Run predictions on GPU
model.to('cuda')
model.predict(X)

Documentation

The API documentation is here.

You can also read about Hummingbird in our blog post here.

For more details on the vision and on the technical details related to Hummingbird, please check our papers:

Contributing

We welcome contributions! Please see the guide on Contributing.

Also, see our roadmap of planned features.

Community

Join our community! Gitter

For more formal enquiries, you can contact us.

Authors

  • Supun Nakandala
  • Matteo Interlandi
  • Karla Saur

License

MIT License

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

hummingbird-ml-0.0.5.tar.gz (39.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hummingbird_ml-0.0.5-py2.py3-none-any.whl (60.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file hummingbird-ml-0.0.5.tar.gz.

File metadata

  • Download URL: hummingbird-ml-0.0.5.tar.gz
  • Upload date:
  • Size: 39.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.5.6

File hashes

Hashes for hummingbird-ml-0.0.5.tar.gz
Algorithm Hash digest
SHA256 07fc2e2f839aa93c3d57582232676d3791f3240d44aec4436f2b45076d072ded
MD5 daac0ef60fffe2bc7ac52c5d1c041a60
BLAKE2b-256 23caae7a6b48b6273ad26db6ed6229afb119e3501d914ab49c03a6afe059f42d

See more details on using hashes here.

File details

Details for the file hummingbird_ml-0.0.5-py2.py3-none-any.whl.

File metadata

  • Download URL: hummingbird_ml-0.0.5-py2.py3-none-any.whl
  • Upload date:
  • Size: 60.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/40.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.5.6

File hashes

Hashes for hummingbird_ml-0.0.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 689ff33021098f4311840965228977aa83fd7c3cee28b375e129206dd4b4b9ec
MD5 2fa9ab17792f75ec8a45a23fbd649d95
BLAKE2b-256 ed3bcf1b8c1e7531377adead8de29e29b00b5aed380544ad0def4c0188b50d80

See more details on using hashes here.

Supported by

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