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
{{ message }}
Repository navigation
FAQ-D/REF/ENH: use results_class attribute in general #4666
When we create a model that inherits the fit method, then it is convenient to have an attribute that tells the super class which results class to use for creating the results instance.
This is convenient if we have to override or add a few methods to the specific Results instance.
The discrete count models use it for ZeroInflated model, but uses result_class instead of results_class
statespace, GMM and distributed use results_class based on file search
RegressionModel.fit does a specific instance check for OLS, isinstance(self, OLS)
There might be more like this with hardcoded special cases that haven't been changed yet.
Some discrete model like Logit, CountModel have a fit method that essentially only creates the correct results instance and otherwise just delegates to the super(...).fit
We also need the results_wrapper_class, which is also used by statespace models
zero inflated count model uses 4 classes, e.g.
Currently I'm working on subclasses of GLM and some discrete models which should also get an option for results_class. Penalized #4576 currently uses the default Results class without any specific information about the penalization, which needs to be changed.
There are a few more issues or comments in other issues related to this.
So, I think we should add it as general feature for the model classes.
we might also add the corresponding _results_keys in analogy to _init_keys which would bring us closer to a solution for #2393 (except we still retrofit results instances instead of using keywords)
As discussed elsewhere (and FUDed to death, obviously, #3877), implementing such a thing can save a ton of duplicated code, in particular in discrete_model. An example of what this can look like.
Defining these attributes in __init__ is sub-optimal. Too many attributes are already defined in __init__/initialize/_initialize/_handle_data and with layered super calls it is not nearly obvious enough what attributes are defined where. More to the point: the desired Results subclass is class-specific, so should be defined at the class-level .
Activity
josef-pkt commentedon May 20, 2018
as a companion
we might also add the corresponding
_results_keysin analogy to_init_keyswhich would bring us closer to a solution for #2393 (except we still retrofit results instances instead of using keywords)jbrockmendel commentedon May 21, 2018
There is precedent in statespace and regime_switching
As discussed elsewhere (and FUDed to death, obviously, #3877), implementing such a thing can save a ton of duplicated code, in particular in
discrete_model. An example of what this can look like.Defining these attributes in
__init__is sub-optimal. Too many attributes are already defined in__init__/initialize/_initialize/_handle_dataand with layeredsupercalls it is not nearly obvious enough what attributes are defined where. More to the point: the desired Results subclass is class-specific, so should be defined at the class-level .