-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
SelectFromModel does not work when ElasticNetCV has multiple l1 ratios #30936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi, |
Thanks for the issue, this looks like a real bug. I have to say I am not sure how to handle this case off the top of my head ... @vasco-s-pereira great if you are looking to contribute to scikit-learn, I would suggest you look at the Contributing doc and New Issues for contributors. |
…array with only floats. Added the _is_l1_ratio_one function in _from_model.py where it checks if the l1_ratio is an array, list or tuple and, in that case, extends np.isclose to the whole array using np.any so that, if atleast on value is approximately equal to 1.0 it returns True.
…rray with only floats. Added the _is_l1_ratio_one function in _from_model.py and a few tests.
Added `_is_l1_ratio_one` function to handle l1_ratio as array, list, or tuple. Uses `np.isclose` and `np.any` to check if at least one element is approximately equal to 1.0.
Added `_is_l1_ratio_one` function to handle l1_ratio as array, list, or tuple. Uses `np.isclose` and `np.any` to check if at least one element is approximately equal to 1.0.
…that ElasticNetCV works with a list of floats; Add non‑regression test `test_get_feature_names_out_elasticnetcv`
Describe the bug
Using
SelectFromModel
with the automaticElasticNetCV
does not work if thel1_ratio
is estimated from the data, i.e., if the user provides a list of floats.Steps/Code to Reproduce
This fails with:
because
_calculate_threshold
callsnp.isclose(estimator.l1_ratio, 1.0)
which returns an array with as many elements as l1 ratios.Expected Results
Calling
.get_feature_names_out()
should return an ndarray of str according to the best model estimating with CV.Actual Results
Versions
The text was updated successfully, but these errors were encountered: