Skip to main content

Library for probabilistic predictions via gradient boosting.

Project description

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.model_selection import train_test_split
from sklearn.metrics import mean_squared_error

#Load Boston housing dataset
data_url = "http://lib.stat.cmu.edu/datasets/boston"
raw_df = pd.read_csv(data_url, sep=r"\s+", skiprows=22, header=None)
X = np.hstack([raw_df.values[::2, :], raw_df.values[1::2, :2]])
Y = raw_df.values[1::2, 2]

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

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

ngboost-0.5.6.tar.gz (27.1 kB view details)

Uploaded Source

Built Distribution

ngboost-0.5.6-py3-none-any.whl (35.8 kB view details)

Uploaded Python 3

File details

Details for the file ngboost-0.5.6.tar.gz.

File metadata

  • Download URL: ngboost-0.5.6.tar.gz
  • Upload date:
  • Size: 27.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.10.17 Darwin/24.5.0

File hashes

Hashes for ngboost-0.5.6.tar.gz
Algorithm Hash digest
SHA256 683ff400f1862e0419f478ac4462af8a489d24c90b86031163e7c9344935fb15
MD5 b30b3d89b4e966d87986e8aebcf41813
BLAKE2b-256 0e08fd144f425731a361a0cd5baaaff312b7b0d9b3e2d4bc029b770321b09e7e

See more details on using hashes here.

File details

Details for the file ngboost-0.5.6-py3-none-any.whl.

File metadata

  • Download URL: ngboost-0.5.6-py3-none-any.whl
  • Upload date:
  • Size: 35.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.0.1 CPython/3.10.17 Darwin/24.5.0

File hashes

Hashes for ngboost-0.5.6-py3-none-any.whl
Algorithm Hash digest
SHA256 f6cb539b88e3d1a928605cf0d66665839911a1f8616b19eece6ba35669d9e692
MD5 13e5b34ea7939a17ccaeb8f96e4b6578
BLAKE2b-256 e12e6e58543d1881adf415f607de356a6c9936980ea901c7482df91eedce514d

See more details on using hashes here.

Supported by

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