项目作者: stanfordmlgroup

项目描述 :
Natural Gradient Boosting for Probabilistic Prediction
高级语言: Python
项目地址: git://github.com/stanfordmlgroup/ngboost.git
创建时间: 2018-06-21T22:22:40Z
项目社区:https://github.com/stanfordmlgroup/ngboost

开源协议:Apache License 2.0

下载


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

  1. via pip
  2. pip install --upgrade ngboost
  3. via conda-forge
  4. conda install -c conda-forge ngboost

Usage

Probabilistic regression example on the Boston housing dataset:

  1. from ngboost import NGBRegressor
  2. from sklearn.model_selection import train_test_split
  3. from sklearn.metrics import mean_squared_error
  4. #Load Boston housing dataset
  5. data_url = "http://lib.stat.cmu.edu/datasets/boston"
  6. raw_df = pd.read_csv(data_url, sep=r"\s+", skiprows=22, header=None)
  7. X = np.hstack([raw_df.values[::2, :], raw_df.values[1::2, :2]])
  8. Y = raw_df.values[1::2, 2]
  9. X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=0.2)
  10. ngb = NGBRegressor().fit(X_train, Y_train)
  11. Y_preds = ngb.predict(X_test)
  12. Y_dists = ngb.pred_dist(X_test)
  13. # test Mean Squared Error
  14. test_MSE = mean_squared_error(Y_preds, Y_test)
  15. print('Test MSE', test_MSE)
  16. # test Negative Log Likelihood
  17. test_NLL = -Y_dists.logpdf(Y_test).mean()
  18. 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