Skip to main content

sklearn_ensemble_cv is a Python module for performing accurate and efficient ensemble cross-validation methods.

Project description

PyPI PyPI-Downloads

Ensemble-cross-validation

sklearn_ensemble_cv is a Python module for performing accurate and efficient ensemble cross-validation methods from various projects.

Features

  • The module builds on scikit-learn/sklearn to provide the most flexibility on various base predictors.
  • The module includes functions for creating ensembles of models, training the ensembles using cross-validation, and making predictions with the ensembles.
  • The module also includes utilities for evaluating the performance of the ensembles and the individual models that make up the ensembles.
from sklearn.tree import DecisionTreeRegressor
from sklearn_ensemble_cv import ECV

# Hyperparameters for the base regressor
grid_regr = {    
    'max_depth':np.array([6,7], dtype=int), 
    }
# Hyperparameters for the ensemble
grid_ensemble = {
    'max_features':np.array([0.9,1.]),
    'max_samples':np.array([0.6,0.7]),
    'n_jobs':-1 # use all processors for fitting each ensemble
}

# Build 50 trees and get estimates until 100 trees
res_ecv, info_ecv = ECV(
    X_train, y_train, DecisionTreeRegressor, grid_regr, grid_ensemble, 
    M=50, M_max=100, return_df=True
)

It currently supports bagging- and subagging-type ensembles under square loss. The hyperparameters of the base predictor are listed at sklearn.tree.DecisionTreeRegressor and the hyperparameters of the ensemble are listed at sklearn.ensemble.BaggingRegressor. Using other sklearn Regressors (regr.is_regressor = True) as base predictors is also supported.

Cross-validation methods

This project is currently in development. More CV methods will be added shortly.

  • split CV
  • K-fold CV
  • ECV
  • GCV
  • CGCV
  • CGCV non-square loss
  • ALOCV

Usage

Check out Jupyter Notebooks in the tutorials folder:

Name Description
basics.ipynb Basics about how to apply ECV/CGCV on risk estimation and hyperparameter tuning for ensemble learning.
cgcv_l1_huber.ipynb Custom CGCV for M-estimator: l1-regularized Huber ensembles.

The code is tested with scikit-learn == 1.3.1.

The document is available.

The module can be installed via PyPI:

pip install sklearn-ensemble-cv

MIT License

Copyright (c) 2023 Du Jinhong

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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

sklearn_ensemble_cv-0.2.4.tar.gz (158.6 kB view details)

Uploaded Source

Built Distribution

sklearn_ensemble_cv-0.2.4-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file sklearn_ensemble_cv-0.2.4.tar.gz.

File metadata

  • Download URL: sklearn_ensemble_cv-0.2.4.tar.gz
  • Upload date:
  • Size: 158.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for sklearn_ensemble_cv-0.2.4.tar.gz
Algorithm Hash digest
SHA256 9bbc638a3389c69dda87da9aea7269cdd4934a9cf7b419eb48ec10a167856628
MD5 a949aa615d85f316e2a27fa29b3288f5
BLAKE2b-256 ff0bb09dab4dce895f30c77ff3454704809b1fd5d26a8024373569fadb786f0a

See more details on using hashes here.

File details

Details for the file sklearn_ensemble_cv-0.2.4-py3-none-any.whl.

File metadata

File hashes

Hashes for sklearn_ensemble_cv-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 a2f5ac783c33b8b76fd23bbe3e27d80640e5b9f06bc5393b9150dc6b42942557
MD5 2eda3458045a1943e939b6681eee083f
BLAKE2b-256 e50e86420ce0996673d230d24f9798afce7b90eadf3311db969e8489a752829f

See more details on using hashes here.

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