Registry / ai-ml / hummingbird-ml

hummingbird-ml

JSON →
library0.4.12pypypi✓ verified 83d ago

Hummingbird is a Microsoft-maintained library that converts trained traditional ML models (scikit-learn, LightGBM, XGBoost, PyTorch, ONNX) into tensor computations (PyTorch, TorchScript, ONNX, TVM). It enables GPU acceleration and scaling for legacy models with minimal code changes. Current version 0.4.12, release cadence is irregular (~quarterly). Requires Python >=3.8.

pip install hummingbird-ml
INSTALL
IMPORT
SIG · HUMMINGBIRD-ML
H
hummingbird-ml
ai-mlpythonv0.4.12
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

convert
from hummingbird.ml import convert
from hummingbird import convert
The top-level module is 'hummingbird.ml', not 'hummingbird'.
Hummingbird
from hummingbird.ml import Hummingbird

Convert a scikit-learn RandomForest to PyTorch backend and run inference.

from hummingbird.ml import convert from sklearn.ensemble import RandomForestClassifier import numpy as np # Train a simple model model = RandomForestClassifier(n_estimators=10) X = np.random.rand(100, 4) y = np.random.randint(0, 2, 100) model.fit(X, y) # Convert to PyTorch pytorch_model = convert(model, backend='pytorch') # Make a prediction pytorch_model.predict(X[:5])
Debug
Known issues
gotchaThe `convert` function expects a trained model object, not an untrained estimator. Calling `convert` on an unfitted model will raise an error.
fix
Ensure the model is fitted (trained) before passing to `convert`.
affects: all
gotchaWhen using `backend='pyodide'` (for WebAssembly), the converted model may have different numerical precision, leading to slight prediction differences.
fix
Test predictions for consistency; consider using `backend='onnx'` for cross-platform stability.
affects: >=0.4.0
deprecatedThe `extra_config` parameter in `convert` is deprecated and will be removed in a future version.
fix
Use `convert` without `extra_config`; customizations may be passed via model's `__init__`.
affects: >=0.4.0
breakingSupport for Python 3.6/3.7 was dropped in version 0.4.0. Using older Python will cause import errors.
fix
Upgrade to Python 3.8 or higher.
affects: >=0.4.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'hummingbird.ml'
Package not installed or import path wrong.
fix
Run `pip install hummingbird-ml` and use `from hummingbird.ml import convert`.
AttributeError: 'RandomForestClassifier' object has no attribute 'tree_'
Model is not trained (fitted) before conversion.
fix
Call `.fit(X, y)` on the model before passing to `convert()`.
RuntimeError: Cannot convert this model type to the requested backend
The model type or backend combination is not supported.
fix
Check official docs for supported model-backend pairs. Common: scikit-learn -> pytorch or onnx.
TypeError: __init__() got an unexpected keyword argument 'extra_config'
Using deprecated `extra_config` parameter which has been removed.
fix
Remove `extra_config`; use alternative configuration if needed.
Upgrade
Version history
0.4.12latest on PyPI · released Oct 25, 2024
Audit
Dependencies
torchrequiredRequired for conversion to PyTorch backend; most common use case.
scikit-learnoptionalRequired for loading scikit-learn models; often needed for input.
lightgbmoptionalOptional: needed if converting LightGBM models.
xgboostoptionalOptional: needed if converting XGBoost models.
Agent activity
24 hits · last 30 days
node
22
Perplexity
1
Resources
hummingbird-ml — pip install hummingbird-ml · libregistry