Fractional K-fold cross-validation for hyperparameter optimization
Project description
fcvopt: Fractional cross-validation for hyperparameter optimization
FCVOpt is a Python package for hyperparameter optimization via Fractional Cross-Validation. It implements the methodology from "Fractional cross-validation for optimizing hyperparameters of supervised learning algorithms" using hierarchical Gaussian processes to efficiently optimize ML models by evaluating only a fraction of CV folds.
K-fold cross-validation is more robust than holdout validation, but requires fitting K models per hyperparameter configuration—making it expensive inside an optimization loop. FCVOpt sidesteps this by modeling the correlation structure of fold-wise losses across the hyperparameter space with a hierarchical GP, so that most configurations need only a single fold evaluated.
The documentation is available at https://syerramilli.github.io/fcvopt/.
Features
- Fractional CV optimization via hierarchical Gaussian processes, with support for repeated K-fold cross-validation
- Standard Bayesian optimization with holdout loss, available for both hyperparameter tuning and general black-box optimization
- Fold selection via variance reduction, which chooses the most informative fold to evaluate at each step
- MLflow integration for experiment tracking and model checkpointing
- Acquisition functions: Knowledge Gradient and Lower Confidence Bound
- Works with scikit-learn estimators, XGBoost, and neural networks (via PyTorch-Skorch)
Installation
pip install fcvopt
Quick Start
from fcvopt.optimizers import FCVOpt
from fcvopt.crossvalidation import SklearnCVObj
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import zero_one_loss
from fcvopt.configspace import ConfigurationSpace
from ConfigSpace import Integer, Float
# Define the CV objective
cv_obj = SklearnCVObj(
estimator=RandomForestClassifier(),
X=X, y=y,
loss_metric=zero_one_loss,
task='binary-classification',
n_splits=5,
rng_seed=42
)
# Define the hyperparameter search space
config = ConfigurationSpace()
config.add([
Integer('n_estimators', bounds=(10, 1000), log=True),
Integer('max_depth', bounds=(1, 12), log=True),
Float('max_features', bounds=(0.1, 1), log=True),
])
config.generate_indices()
# Set up the optimizer
optimizer = FCVOpt(
obj=cv_obj.cvloss,
n_folds=cv_obj.cv.get_n_splits(),
config=config,
acq_function='LCB', # 'KG' tends to work better but is slower
fold_selection_criterion='variance_reduction',
tracking_dir='./hpt_opt_runs/',
experiment_name='rf_hpt'
)
# Run 50 trials, using 10 random initializations before switching to acquisition
best_conf = optimizer.optimize(n_trials=50, n_init=10)
optimizer.end_run()
Research
FCVOpt implements the algorithm described in:
"Fractional cross-validation for optimizing hyperparameters of supervised learning algorithms" Suraj Yerramilli and Daniel W. Apley Technometrics (2025) DOI: 10.1080/00401706.2025.2515926
Citing
If you use this code in your research, please cite the following paper:
@article{yerramilli2025fractional,
author = {Suraj Yerramilli and Daniel W. Apley},
title = {Fractional Cross-Validation for Optimizing Hyperparameters of Supervised Learning Algorithms},
journal = {Technometrics},
year = {2025},
doi = {10.1080/00401706.2025.2515926},
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fcvopt-0.5.1.tar.gz.
File metadata
- Download URL: fcvopt-0.5.1.tar.gz
- Upload date:
- Size: 211.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8257917a70424e903c2e655186d0f5629429d6ee803314051998685626d0b268
|
|
| MD5 |
d3ac314d666848721be86bb5db727dfd
|
|
| BLAKE2b-256 |
741267dd5b41f59982e445d5ae2e098a5eee70a9f7d6fcefd84739d26d787685
|
Provenance
The following attestation bundles were made for fcvopt-0.5.1.tar.gz:
Publisher:
publish.yml on syerramilli/fcvopt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fcvopt-0.5.1.tar.gz -
Subject digest:
8257917a70424e903c2e655186d0f5629429d6ee803314051998685626d0b268 - Sigstore transparency entry: 1104477129
- Sigstore integration time:
-
Permalink:
syerramilli/fcvopt@228737236d8e0e6dd379985866d097e669134bfd -
Branch / Tag:
refs/tags/v0.5.1 - Owner: https://github.com/syerramilli
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@228737236d8e0e6dd379985866d097e669134bfd -
Trigger Event:
push
-
Statement type:
File details
Details for the file fcvopt-0.5.1-py3-none-any.whl.
File metadata
- Download URL: fcvopt-0.5.1-py3-none-any.whl
- Upload date:
- Size: 65.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e25df2e98f9756bcdc4c9ad95f5902f0dec190c17b5dc09ef20f9578957607b3
|
|
| MD5 |
f84decd7abd2f53e90fc62a7c7556407
|
|
| BLAKE2b-256 |
ecb0845bf77eea6d460b9159efd4f989c0ee32c4bf60645a61370ddc55967267
|
Provenance
The following attestation bundles were made for fcvopt-0.5.1-py3-none-any.whl:
Publisher:
publish.yml on syerramilli/fcvopt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fcvopt-0.5.1-py3-none-any.whl -
Subject digest:
e25df2e98f9756bcdc4c9ad95f5902f0dec190c17b5dc09ef20f9578957607b3 - Sigstore transparency entry: 1104477200
- Sigstore integration time:
-
Permalink:
syerramilli/fcvopt@228737236d8e0e6dd379985866d097e669134bfd -
Branch / Tag:
refs/tags/v0.5.1 - Owner: https://github.com/syerramilli
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@228737236d8e0e6dd379985866d097e669134bfd -
Trigger Event:
push
-
Statement type: