-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
TST improve messages raised in check_classifier_multioutput #30235
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
base: main
Are you sure you want to change the base?
TST improve messages raised in check_classifier_multioutput #30235
Conversation
"The prediction for multioutput data is expected to be of the same type " | ||
f"as the input y. Got dtype={y_pred.dtype}, dtype.kind={y_pred.dtype.kind} " | ||
f"instead, while input was dtype={y.dtype}, dtype.kind={y.dtype.kind}." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose this is what we're testing. But not entirely sure.
|
||
if hasattr(estimator, "decision_function"): | ||
decision = estimator.decision_function(X) | ||
assert isinstance(decision, np.ndarray) | ||
assert isinstance(decision, np.ndarray), ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So here we're checking the actual type of the output of decision_function
. But this seems wrong(?) when I think of the array API work. WDYT @betatim @ogrisel @OmarManzoor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could check for xp.array
?
dec_pred = (decision > 0).astype(int) | ||
dec_exp = estimator.classes_[dec_pred] | ||
assert_array_equal(dec_exp, y_pred) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This parts is just odd to me. estimator.classes_=[0, 1, 2]
, and we do some fancy indexing using the results from the decision function. I can't imagine a case where this could fail, or to be meaningful, especially since the value 2
from classes_
would never be chosen here.
np.argmax(y_prob[i], axis=1).astype(int), y_pred[:, i] | ||
) | ||
elif not tags.classifier_tags.poor_score: | ||
if not tags.classifier_tags.poor_score: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
decoupling the shape check from the value check, and skipping only the value check if poor_score
@glemaitre I think you've worked on this quite a bit in the past. |
This PR improves error messages raised in
check_classifier_multioutput