Repository navigation
[MRG] Make argument sample_weight optional in multinomials - #13024
david-cortes wants to merge 1 commit into
Conversation
jnothman
left a comment
There was a problem hiding this comment.
These are private, for internal use. If their caller always passes a sample_weight, we should not include this redundant validation. It makes the code harder to understand.
Then how about removing the check in |
|
For what reason? |
In a regular situation, when someone uses these functions outside of scikit-learn’s |
|
But they're only designed for internal use, not for "someone" to use.
|
I realize they start with underscores, but they are IMHO very handy functions that I think also have a lot of usability externally. For me, they are very useful when working on topics like optimizers or active learning, and it’s quite annoying to be initializing the weights every time. |
|
If you use them often, you can either have wrappers around them or get the signature you need with partials. Also, keeping all arguments compulsory in private APIs helps us not to forget to pass any of those parameters as the input to the function and avoid some of the bugs which would happen otherwise. |
|
The binary versions ( How about adding wrappers for logistic and linear functions to |
|
We could modify the checking for the binary case, making sure this is done in the class (i.e., |
|
I think we have problems historically of having optional params in private
functions, and then failing to pass them. I don't think that's a *big* risk
for sample_weight, but I think I am against on making it optional. Rather,
we should update the docstring.
|
|
closing in favor of #13281 |
Functions for multinomial logistic regression (
_multinomial_loss,_multinomial_loss_grad,_multinomial_grad_hess) have an argumentsample_weightwhich, according to documentation, should be optional (like it is for logistic functions), but is actually compulsory.This pull request sets the weights to 1 when they are missing, making the argument optional.
Fixes #13020