Skip to content

ENH: DiscreteModel callback default #3706

Closed

Description

@jbrockmendel

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

Activity

  1. josef-pkt commented on May 26, 2017

    @josef-pkt
    Member

    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.

  2. josef-pkt commented on May 26, 2017

    @josef-pkt
    Member

    I think for users currently the way to overide this is by using as fit argument:
    callback=lambda x : None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions