Skip to main content

A wrapper for conducting Nested Cross-Validation with Bayesian Hyper-Parameter Optimized Gradient Boosting

Project description

Nested Cross-Validation for Bayesian Optimized Gradient Boosting

PyPI version License: GPL v3 Build Status Codacy Badge GitHub last commit


A Python implementation that unifies Nested K-Fold Cross-Validation, Bayesian Hyperparameter Optimization, and Gradient Boosting. Designed for rapid prototyping on small to mid-sized data sets (can be manipulated within memory). Quickly obtains high quality prediction results by abstracting away tedious hyperparameter tuning and implementation details in favor of usability and implementation speed. Bayesian Hyperparamter Optimization utilizes Tree Parzen Estimation (TPE) from the Hyperopt package. Gradient Boosting can be conducted one of three ways. Select between XGBoost, LightGBM, or CatBoost. XGBoost is applied using traditional Gradient Tree Boosting (GTB). LightGBM is applied using its novel Gradient Based One Sided Sampling (GOSS). CatBoost is applied usings its novel Ordered Boosting. NestedHyperBoost can be applied to regression, multi-class classification, and binary classification problems.


  1. Consistent syntax across all Gradient Boosting methods.
  2. Supported Gradient Boosting methods: XGBoost, LightGBM, CatBoost.
  3. Returns custom object that includes common performance metrics and plots.
  4. Developed for readability, maintainability, and future improvement.


  1. Python 3
  2. NumPy
  3. Pandas
  4. MatPlotLib
  5. Scikit-Learn
  6. Hyperopt
  7. XGBoost
  8. LightGBM
  9. CatBoost


## install pypi release
pip install nestedhyperboost

## install developer version
pip install git+


## load libraries
from nestedhyperboost import xgboost
from sklearn import datasets
import pandas

## load data
data_sklearn = datasets.load_iris()
data = pandas.DataFrame(, columns = data_sklearn.feature_names)
data['target'] = pandas.Series(

## conduct nestedhyperboost
results = xgboost.xgb_ncv_classifier(
    data = data,
    y = 'target',
    k_inner = 5,
    k_outer = 5,
    n_evals = 10

## preview results

## preview plots

## model and params
model = results.model
params = results.params


© Nick Kunz, 2019. Licensed under the General Public License v3.0 (GPLv3).


NestedHyperBoost is open for improvements and maintenance. Your help is valued to make the package better for everyone.


Bergstra, J., Bardenet, R., Bengio, Y., Kegl, B. (2011). Algorithms for Hyper-Parameter Optimization.

Bergstra, J., Yamins, D., Cox, D. D. (2013). Making a Science of Model Search: Hyperparameter Optimization in Hundreds of Dimensions for Vision Architectures. Proceedings of the 30th International Conference on International Conference on Machine Learning. 28:I115–I123.

Chen, T., Guestrin, C. (2016). XGBoost: A Scalable Tree Boosting System. Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining. 785–794.

Ke, G., Meng, Q., Finley, T., et al. (2017). LightGBM: A Highly Efficient Gradient Boosting Decision Tree. Proceedings of the 31st International Conference on Neural Information Processing Systems. 3146-3154.

Prokhorenkova, L., Gusev, G., Vorobev, A., et al. (2018). CatBoost: Unbiased Boosting with Categorical Features. Proceedings of the 32nd International Conference on Neural Information Processing Systems. 6639–6649.

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

nestedhyperboost-0.0.3.tar.gz (25.3 kB view hashes)

Uploaded source

Built Distribution

nestedhyperboost-0.0.3-py3-none-any.whl (30.9 kB view hashes)

Uploaded py3

Supported by

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