Release Date: 2026-06-24 Status: Pre-Alpha — initial working implementation
First working end-to-end implementation of EliminationSearchCV. The core elimination loop runs, produces best_params_, and has been validated on real data (Logistic Regression, 4-parameter grid, 5-fold CV).
-
EliminationSearchCVclass — main public API inEliminationSearchCV.py- Constructor:
estimator,param_grid,scoring,cv(default5),elimination_rate(default0.8) fit(X, y)— runs all elimination rounds, returnsselfbest_params_— post-fit attribute, scalar dict ready forestimator.set_params(**best_params_)
- Constructor:
-
Elimination rounds in
fit()- Iterates from
limit=1(single-param combos) up tolimit=n_params(full combos) - After each round, calls
_eliminate_low_scoring_values()to shrink the active grid
- Iterates from
-
_eliminate_low_scoring_values(candidates, scores)— dispatcher- Round 1 (
len(combo) == 1) →_eliminate_single_param_values() - Rounds 2+ (
len(combo) > 1) →_eliminate_multi_param_values() - Guard: returns immediately if
candidatesis empty (preventsIndexError)
- Round 1 (
-
_eliminate_single_param_values(candidates, scores)— Round 1 per-parameter pruning- Builds
{param → {value → best_score}}map from single-key candidates - Sorts each parameter's values by score descending
- Keeps top
max(1, round(n_total × (1 - elimination_rate)))values - Parameters with only 1 value are never eliminated
- Builds
-
_eliminate_multi_param_values(candidates, scores)— Rounds 2+ global ranking- Ranks all candidates by score; keeps top
(1 - elimination_rate)fraction - Rebuilds active grid from the values seen in kept combinations
- Parameters not present in any kept combination retain their current values (not zeroed out)
- Ranks all candidates by score; keeps top
-
_score_candidates(candidates)— cross-validated scoring- Clones the base estimator, sets params, fits on each fold's training split
- Catches any
Exceptionduringfit()(e.g.penalty='l1'+solver='lbfgs'); assigns0.0— invalid combos are eliminated naturally - Returns a list of mean CV scores, parallel to
candidates
-
Utils.py— stateless utility functionsgenerate_param_combinations_with_limit(param_grid, limit)— generates alllimit-parameter combinations usingitertools.combinations×itertools.productgenerate_param_combinations(param_grid)— full Cartesian product (utility, not used in core loop)create_cv_data_sets(X, y, cv, stratified)— returns(X_train, y_train, X_val, y_val)tuples; usesStratifiedKFold(default) orKFold; handles both pandas and NumPy inputsget_model_score(model, X_val, y_val, scoring)— dict-dispatch metric evaluation; raisesValueErrorfor unsupported metrics
-
Supported scoring metrics:
accuracy,precision,recall,f1,roc_auc -
__init__.py— exposesEliminationSearchCVas the top-level import
IndexError: list index out of rangeoncombinations[0]when the active grid shrank to empty — fixed withif not combinations: returnguardmax_iter: [](empty parameter list) caused byelsebranch zeroing out parameters not present in any kept combination — fixed by starting from a copy of the current grid and only updating params that appear in kept combos- Parameters with only 1 value being silently eliminated — fixed with explicit
if n_total == 1: keep_all; continue best_params_returning list-wrapped values ({'C': [1]}) instead of scalars ({'C': 1}) — fixed with dict comprehension{key: vals[0] for ...}ValueError: Solver lbfgs supports only 'l2' or None penaltiescrash — fixed by wrappingmodel.fit()intry/exceptand scoring invalid combinations as0.0AttributeError: 'EliminationSearchCV' object has no attribute 'param_grid_copy'(typo, missing underscore) — fixed, attribute is_param_grid_copy/ now_active_param_grid
- Renamed internal attributes for clarity:
_param_grid_copy→_active_param_grid(communicates that it changes each round)self.folds→self._folds(private, not part of public API)
- Renamed internal methods — replaced
prunewitheliminatethroughout to match the class name:remove_params_scored_low→_eliminate_low_scoring_values_prune_single_param_round→_eliminate_single_param_values_prune_multi_param_round→_eliminate_multi_param_values_get_parameter_scores→_score_candidates
cvdefault changed from1to5(1-fold CV is not meaningful)fit()now returnsself(scikit-learn convention) instead of returningbest_params_dict directlyget_model_score()refactored from chainedifstatements to a dict-dispatch pattern; now raisesValueErroron unknown metric names instead of returningNonesilently- Duplicate imports removed from
Utils.py(from typing import Dict, Listappeared twice; unusedconfusion_matrix,roc_curve,train_test_splitremoved) - All functions and methods now have Google-style docstrings with
Args:,Returns:, and inline before/after data transformation examples
best_score_attribute not yet exposedcv_results_dictionary (GridSearchCV-compatible) not yet implementedn_jobsparallel evaluation not yet implementedverboselogging not yet implemented- No
BaseEstimatorcompatibility (get_params/set_paramson the searcher itself) - Not yet published to PyPI