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
ENH: get design_info from exog if attached, design_info separate from formula interface #2824
I just saw a usecase where we have exog in the model (non formula interface) that is the return of a call to patsy dmatrices. (current unit tests of #2805)
We could reuse this in the same way as in from_formula, e.g. use the names, allow transform in predict and so on.
separate, related issue: I was thinking for a while how we can use and manipulate the design_info without having to go through the formula treatment.
some desired methods would be drop and subset of variables, columns or terms and maintaining and reusing the related formula information. patsy.dmatrices return DesignMatrix which is a subclass of np.ndarray, but returns ndarrays on slicing or other operations. However, it looks like np.repeat keeps the DesignMatrix class.
The DesignInfo info object can certainly be separated from the DesignMatrix object -- it is a standalone object, and its __init__ method is even public. (Though I would not particularly recommend trying to create one by hand.)
DesignInfo already supports some drop/subset-like functionality, and more could be added.
My goal in DesignMatrix was that all operations should return plain ndarray -- it's just an ndarray with this extra piece of metadata tacked on to avoid an ugly tuple-return-value, plus a nicer repr. I didn't quite manage this, because numpy is annoying. I'd recommend that if you want to pass around and preserve design info internally, you pass the actual object :-)
Activity
josef-pkt commentedon Feb 18, 2016
@njsmith Thoughts on this?
How much of a standalone life can
design_infoget?Eventually we might want to have a design_info API. For now, patsy is the only one we have and support.
njsmith commentedon Feb 23, 2016
Not sure what the question is exactly :-)
The
DesignInfoinfo object can certainly be separated from theDesignMatrixobject -- it is a standalone object, and its__init__method is even public. (Though I would not particularly recommend trying to create one by hand.)DesignInfoalready supports some drop/subset-like functionality, and more could be added.My goal in
DesignMatrixwas that all operations should return plain ndarray -- it's just an ndarray with this extra piece of metadata tacked on to avoid an ugly tuple-return-value, plus a nicer repr. I didn't quite manage this, because numpy is annoying. I'd recommend that if you want to pass around and preserve design info internally, you pass the actual object :-)josef-pkt commentedon Jan 16, 2019
bump
ENH: check exog for design_info
If the user creates exog using dmatrix, then it has the design_info attribute.
e.g. in one of my GAM examples I had
see also #5342