Skip to content
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

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

Open
josef-pkt opened this issue Dec 2, 2021 · 5 comments
Open

Comments

@josef-pkt
Copy link
Member

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)

@bashtage
Copy link
Member

bashtage commented Dec 2, 2021

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.

@josef-pkt
Copy link
Member Author

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

@bashtage
Copy link
Member

bashtage commented Dec 2, 2021

Not true. Look at the signature at the top.

@bashtage
Copy link
Member

bashtage commented Dec 2, 2021

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.

@josef-pkt
Copy link
Member Author

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

@josef-pkt josef-pkt changed the title ENH: predict(which="_dargs") private which for internal use. ENH: predict(which="_dargs") private which values for internal use. Dec 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants