Skip to content

ENH: predict(which="_dargs") private which values for internal use. #7923

Open

Description

@josef-pkt

I would like to add other returns (which) to model.predict that are for internal use.
However, they might not follow the public, results.predict api (e.g. multi-column returns, or tuple returns)

One possibility would be to add the leading underscore to signal it's private.

The main advantage of reusing predict is the argument handling, exog, exog_xxx, offset, exposure, ....
Also model.predict is reused by results.get_prediction, which would be nice to get standard errors and confint for other statistics.

we could even add out-of-sample loglike_obs and other measures (not sure loglike_obs needs endog)

Activity

  1. bashtage commented on Dec 2, 2021

    @bashtage
    Member

    I think this is a very bad idea from the point of view of API. If you do this it shows up in the docs. Better to take the least worst option of making it an undocumented kwarg. If you really, really want to do this, you could write a custom sentinel value like np._NoValue, e.g., sm._PrivateArgument, that is trivial to test for and makes the use case clear.

  2. josef-pkt commented on Dec 2, 2021

    @josef-pkt
    MemberAuthor

    which which are available does not show up in the docs unless we include them explicitly in the docstring.

    e.g. the list at the bottom in https://www.statsmodels.org/dev/generated/statsmodels.discrete.count_model.GenericZeroInflated.predict.html

  3. bashtage commented on Dec 2, 2021

    @bashtage
    Member

    Not true. Look at the signature at the top.

  4. bashtage commented on Dec 2, 2021

    @bashtage
    Member

    As a rule parameters should never be added without doc strings. Even if this docstring say the attribute is not guaranteed to be there in future versions.

  5. josef-pkt commented on Dec 2, 2021

    @josef-pkt
    MemberAuthor

    which='mean' is the official, public keyword. (And it is replacing now the old linear keyword. in 0.14)

    This would not be adding the which keyword itself. It would only change which keyword values are available.
    It would add some inofficial, private possible values of the which keyword to the official one,

    Instead of the current:

    which str, optional
    Define values that will be predicted. ‘mean’, ‘mean-main’, ‘linear’, ‘mean-nonzero’, ‘prob-zero, ‘prob’, ‘prob-main’ Default is ‘mean’.
    

    We could add that there are additional values for which that are intended for internal use

  6. changed the title [-]ENH: `predict(which="_dargs")` private which for internal use.[/-] [+]ENH: `predict(which="_dargs")` private which values for internal use.[/+] on Dec 2, 2021
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