Skip to main content

A wrapper for conducting Nested Cross-Validation with Bayesian Hyper-Parameter Optimized Linear Regularization

Project description

Nested Cross-Validation for Bayesian Optimized Linear Regularization

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

Description

A Python implementation that unifies Nested K-Fold Cross-Validation, Bayesian Hyperparameter Optimization, and Linear Regularization. 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. Linear Regularization can be conducted one of three ways. Select between Ridge, Lasso, or Elastic-Net. Useful where linear regression is applicable.

Features

  1. Consistent syntax across all Linear Regularization methods.
  2. Supported Linear Regularization methods: Ridge, Lasso, Elastic-Net.
  3. Returns custom object that includes common performance metrics and plots.
  4. Developed for readability, maintainability, and future improvement.

Requirements

  1. Python 3
  2. NumPy
  3. Pandas
  4. MatPlotLib
  5. Scikit-Learn
  6. Hyperopt

Installation

## install pypi release
pip install nestedhyperline

## install developer version
pip install git+https://github.com/nickkunz/nestedhyperline.git

Usage

## load libraries
from nestedhyperline import regressors
from sklearn import datasets
import pandas

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

## conduct nestedhyperboost
results = regressors.lasso_ncv_regressor(
    data = data,
    y = 'target',
    loss = 'root mean squared error',
    k_inner = 5,
    k_outer = 5,
    n_evals = 100
)

## preview results
results.error_mean()

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

License

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

Contributions

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

References

Bergstra, J., Bardenet, R., Bengio, Y., Kegl, B. (2011). Algorithms for Hyper-Parameter Optimization. https://papers.nips.cc/paper/4443-algorithms-for-hyper-parameter-optimization.pdf.

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. http://proceedings.mlr.press/v28/bergstra13.pdf.

Hoerl, Arthur E., Kennard, Robert W. (1970). Ridge Regression: Biased Estimation for Nonorthogonal Problems. American Statistical Association and American Society for Quality Stable. 12(1):55-67. https://doi.org/10.1080/00401706.1970.10488634.

Tibshirani, R. (1996). Regression Shrinkage and Selection Via the Lasso. Journal of the Royal Statistical Society: Series B (Methodological). 58(1):267-288. https://doi.org/10.1111/j.2517-6161.1996.tb02080.x.

Zou, H., Hastie, T. (2005). Regularization and Variable Selection via the Elastic Net. Journal of the Royal Statistical Society: Series B (Statistical Methodology). 67: 301-320. https://doi.org/10.1111/j.1467-9868.2005.00503.x.

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

nestedhyperline-0.0.3.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nestedhyperline-0.0.3-py3-none-any.whl (25.1 kB view details)

Uploaded Python 3

File details

Details for the file nestedhyperline-0.0.3.tar.gz.

File metadata

  • Download URL: nestedhyperline-0.0.3.tar.gz
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.31.0 CPython/3.7.4

File hashes

Hashes for nestedhyperline-0.0.3.tar.gz
Algorithm Hash digest
SHA256 cdd60cf3a7b746f02c6fec24827132c50ae5eff77796ba5b9fd9e726bd01d5a7
MD5 10a2a2e2ad3090162649f6f8628acf18
BLAKE2b-256 deb17ba1bef9686aca67fce8732869ce9044646f43473966c29eebb33ddbab34

See more details on using hashes here.

File details

Details for the file nestedhyperline-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: nestedhyperline-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 25.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.31.0 CPython/3.7.4

File hashes

Hashes for nestedhyperline-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 114e50b3558319252c9c497026f4cc4da9a745647825b8ef0432d96115175716
MD5 43d9436f824554a20c695739b208e851
BLAKE2b-256 0e0ed084cd633f270257f946983be63d25a2c32fd94f2ec44620d0bea6bb699d

See more details on using hashes here.

Supported by

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