You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In discrete_model.FOOModel.fit the callback kwarg defaults to self._check_perfect_pred when the user passes None. But what if the user actually doesn't want a a callback? In fitting a bunch of Logit models I found that these callbacks took just under 24% of the runtime.
Not sure what Best Practices are for this, but one idea is a dummy/sentinel class like
class _NoCallback(object): pass
nocallback = _NoCallback()
del _NoCallback
[...]
def fit([...])
callback = callback or self._check_perfect_pred
if callback is nocallback:
callback = None
I never really reviewed the callback (except making perfect prediction exception optional, IIRC)
for example Why is it in DiscreteModel? Currently we only use it in the binary models, Logit and Probit. Also using cdf for predict should be only for binary models.
A possibility to reduce work is to not make the check at each iteration.
(For example I added a convergence cycle check in QuantileRegression, but limits the checks to if (n_iter >= 300) and (n_iter % 100 == 0):
The perfect separation check is supposed to catch cases where we don't get convergence because a parameter goes to inf or similar. So we don't have to check during the early iterations. I guess we need to check after it converged, because it might converge just because of loose convergence criteria.
beside using a sentinel for callback, it would be possible to add more options through the self.raise_on_perfect_prediction = True attribute. I don't see right now how users are supposed to set it.
Activity
josef-pkt commentedon May 26, 2017
I never really reviewed the callback (except making perfect prediction exception optional, IIRC)
for example Why is it in DiscreteModel? Currently we only use it in the binary models, Logit and Probit. Also using cdf for predict should be only for binary models.
A possibility to reduce work is to not make the check at each iteration.
(For example I added a convergence cycle check in QuantileRegression, but limits the checks to
if (n_iter >= 300) and (n_iter % 100 == 0):The perfect separation check is supposed to catch cases where we don't get convergence because a parameter goes to inf or similar. So we don't have to check during the early iterations. I guess we need to check after it converged, because it might converge just because of loose convergence criteria.
beside using a sentinel for callback, it would be possible to add more options through the
self.raise_on_perfect_prediction = Trueattribute. I don't see right now how users are supposed to set it.josef-pkt commentedon May 26, 2017
I think for users currently the way to overide this is by using as fit argument:
callback=lambda x : None