{"id":21611,"library":"ngboost","title":"NGBoost","description":"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.","status":"active","version":"0.5.10","language":"python","source_language":"en","source_url":"https://github.com/stanfordmlgroup/ngboost","tags":["probabilistic-ml","gradient-boosting","uncertainty-quantification","ngboost","bayesian"],"install":[{"cmd":"pip install ngboost","lang":"bash","label":"Install via pip"}],"dependencies":[{"reason":"Core dependency for all models; version compatibility critical.","package":"scikit-learn","optional":false},{"reason":"Core dependency for arrays and numeric operations.","package":"numpy","optional":false},{"reason":"Used for distributions and optimization.","package":"scipy","optional":false},{"reason":"Optional for example usage; not required for core.","package":"pandas","optional":true}],"imports":[{"note":"","wrong":"","symbol":"NGBRegressor","correct":"from ngboost import NGBRegressor"},{"note":"Common error: trying to import from submodule instead of top-level","wrong":"from ngboost.ngboost import NGBClassifier","symbol":"NGBClassifier","correct":"from ngboost import NGBClassifier"},{"note":"Distributions are in ngboost.distns, not top-level.","wrong":"from ngboost import Normal","symbol":"Normal","correct":"from ngboost.distns import Normal"},{"note":"Scores are in ngboost.scores submodule.","wrong":"from ngboost import LogScore","symbol":"LogScore","correct":"from ngboost.scores import LogScore"}],"quickstart":{"code":"import numpy as np\nfrom ngboost import NGBRegressor\nfrom ngboost.distns import Normal\nfrom ngboost.scores import LogScore\n\n# Generate sample data\nnp.random.seed(42)\nX = np.random.randn(100, 1)\ny = X[:, 0] + 0.1*np.random.randn(100)\n\n# Train probabilistic model\nngb = NGBRegressor(Dist=Normal, Score=LogScore, n_estimators=100, learning_rate=0.01, verbose=False)\nngb.fit(X, y)\n\n# Predict: mean and variance (or scale) of Normal distribution\ny_preds = ngb.predict(X)\n# Use ngb.pred_dist(X) to get distribution object","lang":"python","description":"Basic usage of NGBoost for regression with a Normal distribution and LogScore."},"warnings":[{"fix":"Update scikit-learn to >=1.6 or use ngboost<0.5.5","message":"Version 0.5.5 upgraded sklearn dependency to >1.6. If using older sklearn, upgrade or pin ngboost<0.5.5.","severity":"breaking","affected_versions":"0.5.5+"},{"fix":"Pin numpy<2 if using older scikit-learn or custom code that is not numpy2-compatible.","message":"Version 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.","severity":"breaking","affected_versions":"0.5.2+"},{"fix":"Avoid using 'natural_gradient' parameter; default behavior is correct.","message":"The 'natural_gradient' parameter in some internal methods was deprecated in v0.5.8 and may be removed in future.","severity":"deprecated","affected_versions":"0.5.8+"},{"fix":"Always specify both Dist and Score parameters explicitly.","message":"Default 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.","severity":"gotcha","affected_versions":"all"},{"fix":"Use `from ngboost import load_ngboost_model` and call it instead of joblib.load.","message":"Models 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`.","severity":"gotcha","affected_versions":">=0.5.10"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run `pip install ngboost` and ensure you are in the correct Python environment. Then use `from ngboost import NGBRegressor`.","cause":"Incorrect installation or trying to import from a different environment.","error":"ImportError: cannot import name 'NGBRegressor' from 'ngboost'"},{"fix":"Upgrade scikit-learn: `pip install --upgrade scikit-learn`","cause":"Incompatible scikit-learn version (likely <0.22) with newer ngboost.","error":"ModuleNotFoundError: No module named 'sklearn.metrics._pairwise_distances'"},{"fix":"Use `ngb.pred_dist(X)` for ngboost>=0.5.0; for older versions use `ngb.predict_dist(X)`.","cause":"Using an older version of ngboost where the method is called `predict_dist` instead of `pred_dist`.","error":"AttributeError: 'NGBRegressor' object has no attribute 'pred_dist'"},{"fix":"Either set `natural_gradient=False` or use a built-in Score like LogScore.","cause":"Attempting to use natural_gradient with a custom Score that doesn't support it.","error":"ValueError: When `natural_gradient` is True, `Score` must be an instance of `LogScore` or a class that implements `natural_gradient`."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}