Registry / ai-ml / ngboost

ngboost

JSON →
library0.5.10pypypi✓ verified 84d ago

NGBoost is a library for probabilistic prediction via gradient boosting that estimates full probability distributions rather than point predictions. Current version is 0.5.10, supporting Python 3.9–3.14. It uses natural gradient boosting to learn parameters of a parametric distribution. Release cadence is periodic, with recent versions adding distribution support (Weibull, HalfNormal, Beta, etc.), numpy2 compatibility, and sklearn compatibility. Maintained by the Stanford ML Group.

pip install ngboost
INSTALL
IMPORT
SIG · NGBOOST
N
ngboost
ai-mlpythonv0.5.10
Install
23.8s avg
Import
9458ms
Disk
529MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.5.10 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
build_error
glibc
py 3.103.95 runs
installs and imports cleanly · install 23.8s · import 9.458s · 497MB
529MB installed
● package 529MB
Code
Verified usage

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

NGBRegressor
from ngboost import NGBRegressor
NGBClassifier
from ngboost import NGBClassifier
from ngboost.ngboost import NGBClassifier
Common error: trying to import from submodule instead of top-level
Normal
from ngboost.distns import Normal
from ngboost import Normal
Distributions are in ngboost.distns, not top-level.
LogScore
from ngboost.scores import LogScore
from ngboost import LogScore
Scores are in ngboost.scores submodule.

Basic usage of NGBoost for regression with a Normal distribution and LogScore.

import numpy as np from ngboost import NGBRegressor from ngboost.distns import Normal from ngboost.scores import LogScore # Generate sample data np.random.seed(42) X = np.random.randn(100, 1) y = X[:, 0] + 0.1*np.random.randn(100) # Train probabilistic model ngb = NGBRegressor(Dist=Normal, Score=LogScore, n_estimators=100, learning_rate=0.01, verbose=False) ngb.fit(X, y) # Predict: mean and variance (or scale) of Normal distribution y_preds = ngb.predict(X) # Use ngb.pred_dist(X) to get distribution object
Debug
Known issues
breakingVersion 0.5.5 upgraded sklearn dependency to >1.6. If using older sklearn, upgrade or pin ngboost<0.5.5.
fix
Update scikit-learn to >=1.6 or use ngboost<0.5.5
affects: 0.5.5+
breakingVersion 0.5.2 added support for Numpy 2.0. Code relying on numpy<2 behavior (e.g., object dtype in arrays) may break with ngboost>=0.5.2.
fix
Pin numpy<2 if using older scikit-learn or custom code that is not numpy2-compatible.
affects: 0.5.2+
deprecatedThe 'natural_gradient' parameter in some internal methods was deprecated in v0.5.8 and may be removed in future.
fix
Avoid using 'natural_gradient' parameter; default behavior is correct.
affects: 0.5.8+
gotchaDefault distribution is Normal with LogScore. If you use a different distribution, ensure the Score matches the distribution (e.g., LogScore for exponential family). Mismatch leads to silent poor performance.
fix
Always specify both Dist and Score parameters explicitly.
affects: all
gotchaModels saved with sklearn <1.3 may not load with sklearn >=1.3 due to pickle format. ngboost>=0.5.10 includes a compatibility loader `load_ngboost_model`.
fix
Use `from ngboost import load_ngboost_model` and call it instead of joblib.load.
affects: >=0.5.10
Errors
Common errors & fixes
ImportError: cannot import name 'NGBRegressor' from 'ngboost'
Incorrect installation or trying to import from a different environment.
fix
Run `pip install ngboost` and ensure you are in the correct Python environment. Then use `from ngboost import NGBRegressor`.
ModuleNotFoundError: No module named 'sklearn.metrics._pairwise_distances'
Incompatible scikit-learn version (likely <0.22) with newer ngboost.
fix
Upgrade scikit-learn: `pip install --upgrade scikit-learn`
AttributeError: 'NGBRegressor' object has no attribute 'pred_dist'
Using an older version of ngboost where the method is called `predict_dist` instead of `pred_dist`.
fix
Use `ngb.pred_dist(X)` for ngboost>=0.5.0; for older versions use `ngb.predict_dist(X)`.
ValueError: When `natural_gradient` is True, `Score` must be an instance of `LogScore` or a class that implements `natural_gradient`.
Attempting to use natural_gradient with a custom Score that doesn't support it.
fix
Either set `natural_gradient=False` or use a built-in Score like LogScore.
Upgrade
Version history
0.5.10latest on PyPI · released Mar 24, 2026
Audit
Dependencies
scikit-learnrequiredCore dependency for all models; version compatibility critical.
numpyrequiredCore dependency for arrays and numeric operations.
scipyrequiredUsed for distributions and optimization.
pandasoptionalOptional for example usage; not required for core.
Agent activity
32 hits · last 30 days
node
30
Resources
ngboost — pip install ngboost · libregistry