-
-
Notifications
You must be signed in to change notification settings - Fork 25.5k
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
RFC Expose a plublic method to compute the objective function #28169
Comments
I think the We might not want not expose an estimator-specific When this private method is present, the callbacks would attempt to use the private method first by looking up kwargs names from the signature from the fit state (or assume that they are present as attributes on self, updated at each iteration of About the return value(s) of this method: I think it should be more than a scalar or a fixed number of scalars, but instead a dataclass (or namedtuple):
If we return a dataclass, we can have an HTML repr for notebooks. |
I opened #28505 which implements it for NMF to help moving forward with this discussion.
I agree and made it a dataclass
I think it's better to have it in the public method because callbacks are public and users can write custom callbacks so they should not have to rely on a private method.
Thinking more about it, I think that it's better to have 1 keyword param per fitted parameter of the model instead of a single param being a dict. The callback documentation will mention that if a callback needs to compute the objective function on the train set, the |
I suspect that there might be cases that we have in |
That's a good point. I guess I was planning to add a For the context, my motivation for being able to provide fit state parameters comes from when a callback would need to compute the objective function on the training set. It doesn't apply for any other metric and it doesn't apply for the validation set. And it's just to speed-up the computation, avoiding to call So I'm wondering if we really need to have this/these param(s) at all. Maybe we can just accept that computing the objective function on the train set is as fast as computing it on the validation set, despite knowing that it could be done faster. What do you think ? |
Indeed, let's start simple and consider adding API complexity only when it is really justified. |
I think that it would be valuable that all estimators that optimize some objective function expose a public method to compute it.
My main motivation is for the callbacks, for early stopping or monitoring, but I'm sure it would be useful in other contexts.
To really be practical, the signature should be the same across all estimators. What I have in mind is something like:
If we want to compute the objective function of the training set during fitting, we could allow to provide the current variables that are required to compute it at a given iteration, encapsulated in a single argument (a dict):
where the content of fit_state would be estimator specific, and detailed in the docstring of
objective_function
for each estimator.The text was updated successfully, but these errors were encountered: