-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
Description
proposed by @lesteve in #9786 (comment) and #9903 (comment)
in this PR we spotted a place where check_consistent_lengths(X, y) was used where check_consistent_lengths(X, y, sample_weight) should have called it would be good to double-check that this error is not present in some other places in our codebase.
Note what I had originally in mind was something a bit more generic than just doing it for metrics i.e. checking that each time a function signature had sample_weight, there was a check_consistent_length(..., ..., sample_weight) call within its body. Not sure how easy this though.
After going through all the public functions, it seems that the following functions do not check the shape of sample_weight and rely on certain statement to block the code from running through. (See #9903 (comment) for more detail)
DummyClassifier
KernelRidge
LinearRegression, RANSACRegressor, Ridge, RidgeClassifier
MultinomialNB, ComplementNB, BernoulliNBThis may cause:
(1)Users can't get meaningful error message (e.g., now you may get something like operands could not be broadcast together with shapes (2,1) (3,1))
(2)Sometimes all the statements fail to block the code and you even can't get an erorr (e.g., roc_auc_score previously)
It is not difficult to fix the code but the core issue here is how to test it in an elegant way. Also see #5367, #5515.