Skip to main content

Ensemble Cross-validation is a Python package for performing specialized cross-validation on ensemble models, such as extrapolated cross-validation (ECV), generalized cross-validation (GCV), and etc. The implementation of ensemble models are based on scikit-learn.

Project description

Documentation Status 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

The module can be installed via PyPI:

pip install sklearn-ensemble-cv

The document is available. Check out Jupyter Notebook tutorials in the document:

Name Description
basics Basics about how to apply ECV/CGCV on risk estimation and hyperparameter tuning for ensemble learning.
gcv CCV for tuning regularization parameters for non-ensemble ridge, lasso, and elastic net.
cgcv_l1_huber Custom CGCV for M-estimator: l1-regularized Huber ensembles.
multitask Apply ECV on risk estimation and hyperparameter tuning for multi-task ensemble learning.
random_forests Apply ECV on model selection of random forests via a simple utility function.

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

Citation

If you find this package useful for your research, please consider citing our research paper:

Method Reference
ECV Du, J. H., Patil, P., Roeder, K., & Kuchibhotla, A. K. (2024). Extrapolated cross-validation for randomized ensembles. Journal of Computational and Graphical Statistics, 1-12.
GCV Du, J. H., Patil, P., & Kuchibhotla, A. K. (2023). Subsample ridge ensembles: equivalences and generalized cross-validation. In Proceedings of the 40th International Conference on Machine Learning (pp. 8585-8631).
Patil, P., & Du, J. H. (2024). Generalized equivalences between subsampling and ridge regularization. Advances in Neural Information Processing Systems, 36.
CGCV Bellec, P. C., Du, J. H., Koriyama, T., Patil, P., & Tan, K. (2024). Corrected generalized cross-validation for finite ensembles of penalized estimators. Journal of the Royal Statistical Society Series B: Statistical Methodology, qkae092.
CGCV (non-square loss) Koriyama, T., Patil, P., Du, J. H., Tan, K., & Bellec, P. C. (2024). Precise asymptotics of bagging regularized M-estimators. arXiv preprint arXiv:2409.15252.

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.5.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

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

sklearn_ensemble_cv-0.2.5-py3-none-any.whl (15.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sklearn_ensemble_cv-0.2.5.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for sklearn_ensemble_cv-0.2.5.tar.gz
Algorithm Hash digest
SHA256 c8c4a78f97795963a52b44e381f7a8d3e9077a02fcc17be83edb72cb9cd110b2
MD5 bf22e54b68d89563b966b84e2681eb07
BLAKE2b-256 8c8b0ac3b7c67455391ecb806609cc37aefd5345bb515d1640c47a30b551f9e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for sklearn_ensemble_cv-0.2.5.tar.gz:

Publisher: publish-to-pypi.yml on jaydu1/ensemble-cross-validation

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for sklearn_ensemble_cv-0.2.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a08efc8eaf051374c45325b322f495971041def12cbcab0903c6e5df4447d20f
MD5 da6c1eb44041f88b5a684697eaf78ca8
BLAKE2b-256 996481fbe4501b6ba4b858ad10459831053f9f47846d4e53d932d8257ab47979

See more details on using hashes here.

Provenance

The following attestation bundles were made for sklearn_ensemble_cv-0.2.5-py3-none-any.whl:

Publisher: publish-to-pypi.yml on jaydu1/ensemble-cross-validation

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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