ENH Allow 0<p<1 for Minkowski metric#26760
Conversation
|
CI failing since Scipy issue for reference: scipy/scipy#15055 |
Rather than bumping the minimum dependency, we can instead modify the tests based on what the installed version of |
…ce_when_p_less_than_1
…ce_when_p_less_than_1
|
Side note: As per scipy release notes, |
|
We should update the documentation of |
jeremiedbb
left a comment
There was a problem hiding this comment.
Thanks for the PR @Shreesha3112. Just a few comments, looks good otherwise
doc/whats_new/v1.4.rst
Outdated
| - |Enhancement| The `"Minkowski"` metric of :class:`metrics.DistanceMetric` now accepts | ||
| parameter `p` values in the open interval (0,1). |
There was a problem hiding this comment.
I'd rather have a higher level message more related to the original issue, like say that NearestNeighbors now works with p < 1 regardless of the dtype of X, and mark this entry as a |Fix|
…ce_when_p_less_than_1
Co-authored-by: Jérémie du Boisberranger <34657725+jeremiedbb@users.noreply.github.com>
|
One last thing that I forgot to ask yesterday: please add a non-regression test for this; something like the reproducer given in the linked issue #26548 (comment). |
Added non-regression test |
Micky774
left a comment
There was a problem hiding this comment.
This also impacts other estimators -- really any that directly use MinkowskiDistance{32, 64} -- should we document this change for them as well in this PR? What do you think @jeremiedbb?
Otherwise looks good, thanks!
Co-authored-by: Meekail Zain <34613774+Micky774@users.noreply.github.com>
jeremiedbb
left a comment
There was a problem hiding this comment.
LGTM. Thanks @Shreesha3112
I updated the message to be more generic about neighbors based estimators |
…learn#26760) Co-authored-by: Jérémie du Boisberranger <34657725+jeremiedbb@users.noreply.github.com> Co-authored-by: Meekail Zain <34613774+Micky774@users.noreply.github.com>
…learn#26760) Co-authored-by: Jérémie du Boisberranger <34657725+jeremiedbb@users.noreply.github.com> Co-authored-by: Meekail Zain <34613774+Micky774@users.noreply.github.com>
Co-authored-by: Jérémie du Boisberranger <34657725+jeremiedbb@users.noreply.github.com> Co-authored-by: Meekail Zain <34613774+Micky774@users.noreply.github.com>
…learn#26760) Co-authored-by: Jérémie du Boisberranger <34657725+jeremiedbb@users.noreply.github.com> Co-authored-by: Meekail Zain <34613774+Micky774@users.noreply.github.com>
Reference Issues/PRs
Fixes #26548
What does this implement/fix? Explain your changes.
Currently
MinkowskiDistancemetricraises ValueError("p must be greater than 1")ifp<1. This PR allows0<p<1.Any other comments?