Nested Cross-Validation for Bayesian Optimized Linear Regularization
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
- Consistent syntax across all Linear Regularization methods.
- Supported Linear Regularization methods: Ridge, Lasso, Elastic-Net.
- Returns custom object that includes performance metrics and plots.
- Developed for readability, maintainability, and future improvement.
Requirements
- Python 3
- NumPy
- Pandas
- MatPlotLib
- Seaborn
- Scikit-Learn
- 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
housing_sklearn = datasets.load_boston()
housing = pandas.DataFrame(housing_sklearn.data, columns = housing_sklearn.feature_names)
housing['target'] = pandas.Series(housing_sklearn.target)
## conduct lasso regression
results = regressors.lasso_ncv_regressor(
data = housing,
y = 'target',
loss = 'mse',
k_inner = 3,
k_outer = 3,
n_evals = 300
)
## preview performance
results.error_mean()
## preview plots
results.plot_error_mean()
results.plot_lambda()
results.plot_regular()
results.plot_coef()
Examples
https://github.com/nickkunz/nestedhyperline/blob/master/examples/nestedhyperline_example_ridge.ipynb
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.
Metadata
Release files for nestedhyperline 0.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nestedhyperline-0.0.6.tar.gz | 25.3 kB | Without provenance | Details for nestedhyperline-0.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nestedhyperline-0.0.6-py3-none-any.whl | Python 3 | none | any | Details for nestedhyperline-0.0.6-py3-none-any.whl |
Total release size: 53.7 kB
Release files / nestedhyperline-0.0.6.tar.gz
| Download URL | nestedhyperline-0.0.6.tar.gz |
|---|---|
| Size | 25.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
59b0b7fe493002c22861ed3b55ccd18857b366e1ea6f0de3f5264986531c3b92
|
|
BLAKE2b-256 checksum How to use checksums |
c36d8e3dcd18cef189e496a07cc1fe8ecc4241e14084d294ebc56e581e108b7a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / nestedhyperline-0.0.6-py3-none-any.whl
| Download URL | nestedhyperline-0.0.6-py3-none-any.whl |
|---|---|
| Size | 28.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b711d42bfbc2efd84ca15d1ab83580ef43f5b0b39ef272afd53c786c112f39a0
|
|
BLAKE2b-256 checksum How to use checksums |
3701b59183dc72fbc50180f05463785d04bef7c649e5debdf52285452cd4b7ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Security for nestedhyperline 0.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.