Stateful transforms compatible with 'mgcv' R package#43
Stateful transforms compatible with 'mgcv' R package#43njsmith merged 19 commits intopydata:masterfrom
Conversation
New 'cr/cs', 'cc' and 'te' stateful transforms matching what is found in the 'mgcv' R package.
|
PS: current stateful_transforms classes need obviously some more work (but not much i think, see TODOs) to really qualify as genuine stateful_transforms |
Stateful transforms 'cr'/'cs', 'cc' and 'te' contains now true stateful_transform functionality.
|
Some comments on a quick pass:
Thanks! |
|
Thank you for your comments but please note that in fact the code committed so far was only meant to give you a quick idea of what it looks like, I should have mentioned that, sorry. |
|
Ah, that makes sense -- let me know when this is ready to review, then, I On Fri, May 23, 2014 at 7:13 PM, broessli notifications@github.com wrote:
Nathaniel J. Smith |
- Reworked all code: pep8 compliance, added proper docstrings - Added special treatment for values outside knots range for 'cr/cs' - Reworked 'te' api to have full control on constraints application/derivation - Added basic tests, to be completed with full scale R comparisons
|
Yep, I'll let you know when this is ready. |
|
Hi, the code is now ready to review, thanks! |
patsy/mgcv_cubic_splines.py
Outdated
There was a problem hiding this comment.
I don't actually own the copyright to this code so you probably shouldn't say I do :-). Please put whoever actually owns the copyright (I guess probably the company you work for?).
There was a problem hiding this comment.
Yep that would be my company (GDF Suez)
|
About the warnings vs errors, this is to reproduce mgcv behavior precisely, see also R test cases |
patsy/mgcv_cubic_splines.py
Outdated
There was a problem hiding this comment.
- Can we call this
constraintor something instead ofcons? - I don't like the quirky
True/Falsemeanings -- how about we allow either an array or the string"center"? - Could you explain somewhere what the constraints actually are? Both why you might want a constraint, and how the array (if given) is interpreted?
There was a problem hiding this comment.
(Same applies to the other classes that use cons= of course.)
There was a problem hiding this comment.
Yes I'll change that indeed, and add some doc about constraints. Interpretation of the constraints array is currently only described in _get_te_dmatrix, _get_crs_dmatrix and _absorb_constraints.
|
The test failures are because (a) latest pandas seems to have dropped python 2.6 support, oops, and (b) tests/check-API-refs.py is detecting that new functions have been added to the patsy.* namespace, but not to the docs. The underlying issue here is that the docs are only partially automatic: they will pull out docstrings, but only when explicitly requested. So we need to add some entries to But this also means that we'll have to somewhat rearrange the docs you've already written. We don't want to explicitly add the |
doc/spline-regression.rst
Outdated
|
That's all I noticed on this pass :-) A few details to sort out, but this is looking pretty good! |
|
Thanks a lot for your code review! |
|
On Sun, Jun 29, 2014 at 8:17 PM, broessli notifications@github.com wrote:
Nathaniel J. Smith |
|
Hi, just to let you know I've addressed all the points raised during last review! |
patsy/mgcv_cubic_splines.py
Outdated
There was a problem hiding this comment.
This could be written more idiomatically as
self._tmp.setdefault("count", 0)
self._tmp["count"] += tp.shape[0]
There was a problem hiding this comment.
In fact I first wrote it this way but since I need np.zeros(..) for "sum" in setdefault() it would get evaluated everytime, that's why I changed with if/else. But I agree the idiomatic version is more readable, I'll change that!
|
Looks good, modulo the super-nitpicky comment about |
|
Oh yes sorry I missed one |
|
I've pushed the last corrections, waiting for travis... |
|
Oh, yeah, I missed that about the as well, pick whichever you prefer :-) |
|
OK I'll keep the |
Stateful transforms compatible with 'mgcv' R package
|
Looks good to me! Thanks so much, this was a pleasure to help you with :-) |
|
I'd like to thank you very much for your help and taking the time that you Le samedi 5 juillet 2014, Nathaniel J. Smith notifications@github.com a
Benoît. |
Hi!
I've added the file mgcv.py containing the code for the following stateful transforms: cr/cs, cc and te.
Benoît.