Blame patsy-error-doc.patch
|
|
df37e6a |
diff -ur patsy-0.5.1/doc/stateful-transforms.rst patsy-0.5.1.doc/doc/stateful-transforms.rst
|
|
|
df37e6a |
--- patsy-0.5.1/doc/stateful-transforms.rst 2018-10-28 04:04:50.000000000 +0100
|
|
|
df37e6a |
+++ patsy-0.5.1.doc/doc/stateful-transforms.rst 2018-11-12 21:25:46.469485037 +0100
|
|
|
4e2cb8f |
@@ -35,6 +35,7 @@
|
|
|
4e2cb8f |
Now we can build a design matrix and see what we get:
|
|
|
4e2cb8f |
|
|
|
4e2cb8f |
.. ipython:: python
|
|
|
4e2cb8f |
+ :okexcept:
|
|
|
4e2cb8f |
|
|
|
4e2cb8f |
mat = dmatrix("naive_center(x)", data)
|
|
|
4e2cb8f |
mat
|
|
|
4e2cb8f |
@@ -49,6 +50,7 @@
|
|
|
4e2cb8f |
transformation, like so:
|
|
|
4e2cb8f |
|
|
|
4e2cb8f |
.. ipython:: python
|
|
|
4e2cb8f |
+ :okexcept:
|
|
|
4e2cb8f |
|
|
|
4e2cb8f |
new_data = {"x": [5, 6, 7, 8]}
|
|
|
4e2cb8f |
# Broken!
|
|
|
4e2cb8f |
@@ -76,6 +78,7 @@
|
|
|
4e2cb8f |
way:
|
|
|
4e2cb8f |
|
|
|
4e2cb8f |
.. ipython:: python
|
|
|
4e2cb8f |
+ :okexcept:
|
|
|
4e2cb8f |
|
|
|
4e2cb8f |
fixed_mat = dmatrix("center(x)", data)
|
|
|
4e2cb8f |
fixed_mat
|
|
|
4e2cb8f |
@@ -83,6 +86,7 @@
|
|
|
4e2cb8f |
But if we then feed in our new data, we also get out the correct result:
|
|
|
4e2cb8f |
|
|
|
4e2cb8f |
.. ipython:: python
|
|
|
4e2cb8f |
+ :okexcept:
|
|
|
4e2cb8f |
|
|
|
4e2cb8f |
# Correct!
|
|
|
4e2cb8f |
build_design_matrices([fixed_mat.design_info], new_data)[0]
|
|
|
4e2cb8f |
@@ -97,6 +101,7 @@
|
|
|
4e2cb8f |
just similar enough for you to miss the problem until it's too late.)
|
|
|
4e2cb8f |
|
|
|
4e2cb8f |
.. ipython:: python
|
|
|
4e2cb8f |
+ :okexcept:
|
|
|
4e2cb8f |
|
|
|
4e2cb8f |
data_chunked = [{"x": data["x"][:2]},
|
|
|
4e2cb8f |
{"x": data["x"][2:]}]
|
|
|
4e2cb8f |
@@ -108,6 +113,7 @@
|
|
|
4e2cb8f |
But if we use the proper stateful transform, this just works:
|
|
|
4e2cb8f |
|
|
|
4e2cb8f |
.. ipython:: python
|
|
|
4e2cb8f |
+ :okexcept:
|
|
|
4e2cb8f |
|
|
|
4e2cb8f |
dinfo = incr_dbuilder("center(x)", lambda: iter(data_chunked))
|
|
|
4e2cb8f |
# Correct!
|
|
|
4e2cb8f |
@@ -133,6 +139,7 @@
|
|
|
4e2cb8f |
for prediction as well:
|
|
|
4e2cb8f |
|
|
|
4e2cb8f |
.. ipython:: python
|
|
|
4e2cb8f |
+ :okexcept:
|
|
|
4e2cb8f |
|
|
|
4e2cb8f |
# Correct!
|
|
|
4e2cb8f |
build_design_matrices([dinfo], new_data)[0]
|