Repository navigation
[MRG] sklearn.metrics.normalized_mutual_info_score for continuous data does not return a warning #17892 - #17911
Conversation
[Issue #17892s(#17892) What does this implement/fix? Explain your changes. normalized_mutual_info_score for continuous data does not return a warning
| noise = np.random.rand(500) | ||
| wavelength = np.linspace(0.01, 1, 500) * 1e-6 | ||
|
|
||
| with pytest(UserWarning): |
There was a problem hiding this comment.
| with pytest(UserWarning): | |
| with pytest.warns(UserWarning): |
There was a problem hiding this comment.
@jnothman I made the change. Let me know if I need to change anything else
|
@jnothman do you have any further comments? |
thomasjpfan
left a comment
There was a problem hiding this comment.
The title does not need to reference the PR number, it should only describe what the PR is doing.
Thank you for the PR @dachosen1 !
| warnings.warn(UserWarning('Expects discrete values received {} ' | ||
| 'for label, and {} for target' | ||
| .format(type_label, type_label))) |
There was a problem hiding this comment.
We can use f-strings here:
| warnings.warn(UserWarning('Expects discrete values received {} ' | |
| 'for label, and {} for target' | |
| .format(type_label, type_label))) | |
| warnings.warn(f'Expects discrete values received {type_label} ' | |
| f'for label, and {type_label} for target', | |
| UserWarning) |
Noted. Thanks for the heads up. @thomasjpfan I implemented the suggested changes. Let me know what you think. |
| type_label = type_of_target(labels_true) | ||
| type_pred = type_of_target(labels_pred) |
There was a problem hiding this comment.
A random thought (does not block this PR): We sure call np.unique a bunch. (type_of_target calls np.unique internally).
There was a problem hiding this comment.
A random thought (does not block this PR): We sure call np.unique a bunch. (type_of_target calls np.unique internally).
Yes, this is a problem of not using objects... ideally, instead of unique_labels and type_of_target we should have a Target class that reuses partial results such as unique, to improve efficiency.
|
@jnothman do you have any other comments? |
|
Thanks @dachosen1 |
|
@jnothman this is exciting. Finally completed my first open-source contribution.!!! |
|
Congrats, @dachosen1! |
Reference Issues/PRs
Fixes #17892
What does this implement/fix? Explain your changes.
Fixes an an error where normalized_mutual_info_score for continuous data does not return a warning for continous values
Any other comments?