Skip to main content

NGBoost: Natural Gradient Boosting for Probabilistic Prediction

Python package GitHub Repo Size Github License Code style: black PyPI PyPI Downloads

ngboost is a Python library that implements Natural Gradient Boosting, as described in "NGBoost: Natural Gradient Boosting for Probabilistic Prediction". It is built on top of Scikit-Learn, and is designed to be scalable and modular with respect to choice of proper scoring rule, distribution, and base learner. A didactic introduction to the methodology underlying NGBoost is available in this slide deck.

Installation

via pip

pip install --upgrade ngboost

via conda-forge

conda install -c conda-forge ngboost

Usage

Probabilistic regression example on the Boston housing dataset:

from ngboost import NGBRegressor

from sklearn.datasets import fetch_california_housing
from sklearn.model_selection import train_test_split
from sklearn.metrics import mean_squared_error

# Load California housing dataset
cal = fetch_california_housing()
X, Y = cal.data, cal.target

X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.2)

ngb = NGBRegressor().fit(X_train, Y_train)
Y_preds = ngb.predict(X_test)
Y_dists = ngb.pred_dist(X_test)

# test Mean Squared Error
test_MSE = mean_squared_error(Y_preds, Y_test)
print('Test MSE', test_MSE)

# test Negative Log Likelihood
test_NLL = -Y_dists.logpdf(Y_test).mean()
print('Test NLL', test_NLL)

Details on available distributions, scoring rules, learners, tuning, and model interpretation are available in our user guide, which also includes numerous usage examples and information on how to add new distributions or scores to NGBoost.

License

Apache License 2.0.

Reference

Tony Duan, Anand Avati, Daisy Yi Ding, Khanh K. Thai, Sanjay Basu, Andrew Y. Ng, Alejandro Schuler. 2019. NGBoost: Natural Gradient Boosting for Probabilistic Prediction. arXiv

Release files for ngboost 0.5.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ngboost 0.5.11
File Size Uploaded
ngboost-0.5.11.tar.gz 42.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ngboost 0.5.11
File Interpreter ABI Platform
ngboost-0.5.11-py3-none-any.whl Python 3 none any Details

Total release size: 95.4 kB

Release files / ngboost-0.5.11.tar.gz

Download URL ngboost-0.5.11.tar.gz
Size 42.4 kB
Tags Source
SHA-256 checksum
How to use checksums
873326442f00632829a521209b1030e150e0ef0a9de09952e044f8f3b8839940
BLAKE2b-256 checksum
How to use checksums
6866119fe55e3b0ab091101778b9b7d228ca27b75e5da88c0424f93594a2f236
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.1 CPython/3.13.2 Darwin/25.6.0

Release files / ngboost-0.5.11-py3-none-any.whl

Download URL ngboost-0.5.11-py3-none-any.whl
Size 53.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c3683334ab6ad58d79bc50aa11d8f090f4d452010c73dc2f2304affc448b08fa
BLAKE2b-256 checksum
How to use checksums
52f6c3ede5cc357b2c1c70d626c68ece0c352bac5d5314652b4ad35215ed6bc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.1 CPython/3.13.2 Darwin/25.6.0

Release history Release notifications | RSS feed

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page