Skip to content

Latest commit

 

History

History
94 lines (70 loc) · 5.56 KB

File metadata and controls

94 lines (70 loc) · 5.56 KB

Changelog — v0.0.1

Release Date: 2026-06-24 Status: Pre-Alpha — initial working implementation


Overview

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).


Added

  • EliminationSearchCV class — main public API in EliminationSearchCV.py

    • Constructor: estimator, param_grid, scoring, cv (default 5), elimination_rate (default 0.8)
    • fit(X, y) — runs all elimination rounds, returns self
    • best_params_ — post-fit attribute, scalar dict ready for estimator.set_params(**best_params_)
  • Elimination rounds in fit()

    • Iterates from limit=1 (single-param combos) up to limit=n_params (full combos)
    • After each round, calls _eliminate_low_scoring_values() to shrink the active grid
  • _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 candidates is empty (prevents IndexError)
  • _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
  • _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)
  • _score_candidates(candidates) — cross-validated scoring

    • Clones the base estimator, sets params, fits on each fold's training split
    • Catches any Exception during fit() (e.g. penalty='l1' + solver='lbfgs'); assigns 0.0 — invalid combos are eliminated naturally
    • Returns a list of mean CV scores, parallel to candidates
  • Utils.py — stateless utility functions

    • generate_param_combinations_with_limit(param_grid, limit) — generates all limit-parameter combinations using itertools.combinations × itertools.product
    • generate_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; uses StratifiedKFold (default) or KFold; handles both pandas and NumPy inputs
    • get_model_score(model, X_val, y_val, scoring) — dict-dispatch metric evaluation; raises ValueError for unsupported metrics
  • Supported scoring metrics: accuracy, precision, recall, f1, roc_auc

  • __init__.py — exposes EliminationSearchCV as the top-level import


Fixed

  • IndexError: list index out of range on combinations[0] when the active grid shrank to empty — fixed with if not combinations: return guard
  • max_iter: [] (empty parameter list) caused by else branch 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 penalties crash — fixed by wrapping model.fit() in try/except and scoring invalid combinations as 0.0
  • AttributeError: 'EliminationSearchCV' object has no attribute 'param_grid_copy' (typo, missing underscore) — fixed, attribute is _param_grid_copy / now _active_param_grid

Changed

  • Renamed internal attributes for clarity:
    • _param_grid_copy_active_param_grid (communicates that it changes each round)
    • self.foldsself._folds (private, not part of public API)
  • Renamed internal methods — replaced prune with eliminate throughout 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
  • cv default changed from 1 to 5 (1-fold CV is not meaningful)
  • fit() now returns self (scikit-learn convention) instead of returning best_params_ dict directly
  • get_model_score() refactored from chained if statements to a dict-dispatch pattern; now raises ValueError on unknown metric names instead of returning None silently
  • Duplicate imports removed from Utils.py (from typing import Dict, List appeared twice; unused confusion_matrix, roc_curve, train_test_split removed)
  • All functions and methods now have Google-style docstrings with Args:, Returns:, and inline before/after data transformation examples

Known Limitations

  • best_score_ attribute not yet exposed
  • cv_results_ dictionary (GridSearchCV-compatible) not yet implemented
  • n_jobs parallel evaluation not yet implemented
  • verbose logging not yet implemented
  • No BaseEstimator compatibility (get_params / set_params on the searcher itself)
  • Not yet published to PyPI