Skip to main content

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.

Metadata

Release files for sklearn-ensemble-cv 0.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sklearn-ensemble-cv 0.2.5
File Size Uploaded Provenance
sklearn_ensemble_cv-0.2.5.tar.gz 14.8 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sklearn-ensemble-cv 0.2.5
File Interpreter ABI Platform
sklearn_ensemble_cv-0.2.5-py3-none-any.whl Python 3 none any Details

Total release size: 30.7 kB

Release files / sklearn_ensemble_cv-0.2.5.tar.gz

Download URL sklearn_ensemble_cv-0.2.5.tar.gz
Size 14.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c8c4a78f97795963a52b44e381f7a8d3e9077a02fcc17be83edb72cb9cd110b2
BLAKE2b-256 checksum
How to use checksums
8c8b0ac3b7c67455391ecb806609cc37aefd5345bb515d1640c47a30b551f9e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 8, 2025.

Transparency log

Release files / sklearn_ensemble_cv-0.2.5-py3-none-any.whl

Download URL sklearn_ensemble_cv-0.2.5-py3-none-any.whl
Size 15.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a08efc8eaf051374c45325b322f495971041def12cbcab0903c6e5df4447d20f
BLAKE2b-256 checksum
How to use checksums
996481fbe4501b6ba4b858ad10459831053f9f47846d4e53d932d8257ab47979
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.8

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 8, 2025.

Transparency log

Security for sklearn-ensemble-cv 0.2.5

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for sklearn_ensemble_cv-0.2.5.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 8, 2025.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page