Tags: Quantco/glum
Tags
Monotonic constraints (#996) * Fix nightly test for sklearn ElasticNetCV n_alphas removal sklearn 1.7 renamed the `n_alphas` parameter to `alphas` in `ElasticNetCV`. Dynamically select the correct keyword to support both old and new sklearn versions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix * Fix comment: don't assume sklearn removal version Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * implement monotonic constraints * add explicit test between solvers and consolidate tests * more consistent interface to standard irls solver * pr comments; ci failure * leave p2 in original form (sparse or 1D when there are no violations * add changelog * add to README [skip-ci] * move constraint checks and resolution to single plac * add comments back * remvoe unnecessary branching * sparce constraint matrix * relax tol due to switch to sparse * move validation of mono constr against Ab to hyperparameter validation * test formula vs explicit A_ineq constraint path agreement Renames test to test_monotonic_constraint_paths_agree and adds a formula-based IRLS fit to verify internal constraint matrix building matches explicit A_ineq/b_ineq. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * cleanup * cleanup * validate edge case * relax test tol slightly due to 8e-8 difference resulting from different paths via tabmat SplitMatrix vs. dense numpy array * update changelog for release --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
`GeneralizedLinearRegressorCV`: allow predicting with `alpha` or `alp… …ha_index` and fix alpha path computation (#975) * Add failing test for CV linear_predictor with alpha_index coef_path_ in GeneralizedLinearRegressorCV has shape (n_folds, n_l1_ratios, n_alphas, n_features) but the inherited linear_predictor indexes it as if it were (n_alphas, n_features), causing a broadcast error. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Raise clear error for predict with alpha_index on CV estimator GeneralizedLinearRegressorCV.coef_path_ has shape (n_folds, n_l1_ratios, n_alphas, n_features), which is incompatible with the base class linear_predictor that expects (n_alphas, n_features). Override linear_predictor to raise a ValueError when alpha_index or alpha is passed, directing users to use the default predict (best alpha from the full-data refit). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * allow to predict with alpha_index * fix trailing whitespace * avoid breaking change * Parametrize CV predict test over single and multiple l1_ratios Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Simplify CV linear_predictor by normalizing alpha_index to a list early Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Move alpha/alpha_index mutual exclusion check to top of linear_predictor Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Move alpha_search guard out of _find_alpha_index into linear_predictor The CV class no longer needs to override _find_alpha_index or set alpha_search=True — it simply calls _find_alpha_index (which now assumes _alphas exists) from its own linear_predictor override. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * docstrings * combine shared logic * move more logic into alpha path; type hints * docstring * fix scaling in setup of CV; fix solver name; add equivalence test * wordings * wordings, changelog * reorganize linear predictor; wordings * cosmetics * more tiny cosmetics * erroneous search and replace * review comments * adjust test to informative error message * tiny wording * wordings * add comment on diagnostics * correct type ifnore * update changelog for release --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
PreviousNext