[MRG+2] Norm inconsistency between RFE and SelectFromModel (was _LearntSelectorMixin) #2121#6181
Conversation
|
Thanks! Unfortunately, norm along an axis is not supported in the earliest version of numpy we support. You could add an axis-supporting variant to Also, please add tests. |
There was a problem hiding this comment.
As @jnothman says, you can use sklearn.preprocessing.normalize to handle ord not being supported in older versions of NumPy
|
For the test, I would just say to
|
|
(I think this is more about multiclass than multi-target.) You could On 21 January 2016 at 08:24, Manoj Kumar notifications@github.com wrote:
|
|
Were you referring to the common use-case or to the test that I linked to? |
|
Probably taking your comments out of context. On 21 January 2016 at 08:57, Manoj Kumar notifications@github.com wrote:
|
|
Is multi-target supported here? |
|
It seems so, although untested. |
|
Remind me what the shape of multitarget multiclass |
|
Oh I meant multitarget/multioutput in a regression setting, not "multitarget multiclass" |
|
Oh, okay. On 21 January 2016 at 14:21, Manoj Kumar notifications@github.com wrote:
|
|
Thank you for all these pieces of advice, if all goes well I will update the pull request within this week. |
|
I chose to implement a fix for the norm function in |
|
It seems I got confused with the numpy version to check when implementing the fix (keepdims only exists in numpy 1.10), I'll fix this as soon as possible. |
sklearn/utils/fixes.py
Outdated
There was a problem hiding this comment.
The keepdims argument seems to be YAGNI to me atleast in this context.
There was a problem hiding this comment.
Now that you mention it, it seems silly to have bothered with it !
|
LGTM pending comments |
|
[MRG] -> [MRG+1] |
|
@jnothman Merge? |
|
|
||
| norm_order : non-zero int, inf, -inf, default 1 | ||
| Order of the norm used to filter the vectors of coefficients below | ||
| ``threshold`` in the case where the ``coeff_`` attribute of the |
|
|
any updates on this? |
# Conflicts: # sklearn/feature_selection/tests/test_from_model.py # sklearn/utils/fixes.py # sklearn/utils/tests/test_fixes.py
|
Here are the last fixes, sorry about this ridiculous delay. |
|
@antoinewdg don't sweat it, recently found an issue from 2013 that I forgot to reply to ;) |
| else: | ||
| from numpy.ma import MaskedArray # noqa | ||
|
|
||
| if 'axis' not in signature(np.linalg.norm).parameters: |
There was a problem hiding this comment.
Can you maybe add the numpy version this was added in a comment?
|
Other than that, LGTM, too |
|
Sure! I'm not really sure what version that is though. The docs start mentioning it from 1.8 so I'll go with that, can't find any patch note about that. |
|
While looking for patch notes I stumbled upon this stackoverflow thread. EDIT: no this is stupid, we would have to make a big 'switch' over the order then. |
|
Yeah you should go with when the docs mention it. I'm confused on why you would do einsum instead of the transpose but whatever. The patch looks good :) |
…ntSelectorMixin) scikit-learn#2121 (scikit-learn#6181) * Norm inconsistency between RFE and SelectFromModel (was _LearntSelectorMixin) scikit-learn#2121 * safe_pwr utility * Norm fix * Removed safe_pwr * 1D arrays support for norm fix * Test case for 2d coef in SelectFromModel * Fix numpy version requirement for norm fix * Implement fixes suggested by @jnothman * Add numpy version requiring the fix.
…ntSelectorMixin) scikit-learn#2121 (scikit-learn#6181) * Norm inconsistency between RFE and SelectFromModel (was _LearntSelectorMixin) scikit-learn#2121 * safe_pwr utility * Norm fix * Removed safe_pwr * 1D arrays support for norm fix * Test case for 2d coef in SelectFromModel * Fix numpy version requirement for norm fix * Implement fixes suggested by @jnothman * Add numpy version requiring the fix.
…ntSelectorMixin) scikit-learn#2121 (scikit-learn#6181) * Norm inconsistency between RFE and SelectFromModel (was _LearntSelectorMixin) scikit-learn#2121 * safe_pwr utility * Norm fix * Removed safe_pwr * 1D arrays support for norm fix * Test case for 2d coef in SelectFromModel * Fix numpy version requirement for norm fix * Implement fixes suggested by @jnothman * Add numpy version requiring the fix.
…ntSelectorMixin) scikit-learn#2121 (scikit-learn#6181) * Norm inconsistency between RFE and SelectFromModel (was _LearntSelectorMixin) scikit-learn#2121 * safe_pwr utility * Norm fix * Removed safe_pwr * 1D arrays support for norm fix * Test case for 2d coef in SelectFromModel * Fix numpy version requirement for norm fix * Implement fixes suggested by @jnothman * Add numpy version requiring the fix.
As @jnothman mentionned in the mailing list it would be nice to also add this option for RFE. The unit tests for RFE cover the case of a sparse coeff matrix, which I have trouble to handle, so I would need a little help if this were to be done.