Skip to content

Commit d0b5b3c

Browse files
Merge pull request #217 from bashtage/add-cubic-regression-spline
ENH: Add cubic regression spline
2 parents a40cf84 + 488be26 commit d0b5b3c

File tree

9 files changed

+9048
-16
lines changed

9 files changed

+9048
-16
lines changed

docsite/docs/changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ For changes since the latest tagged release, please refer to the
33

44
---
55

6+
## 1.1.0 (Unreleased)
7+
8+
** Enhancements **
9+
10+
* Added cubic spline support for cyclic (`cc`) and natural (`cr`). See
11+
`formulaic.materializers.transforms.cubic_spline.cubic_spline` for
12+
more details.
13+
614
## 1.0.2 (12 July 2024)
715

816
**Bugfixes and cleanups:**

docsite/docs/guides/grammar.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ that have *not* been implemented by `formulaic` are explicitly noted also.
6868
| `lag(...[, <k>])` | Generate lagging or leading columns (useful for datasets collected at regular intervals). ||||
6969
| `poly(...)` | Generates a polynomial basis, allowing non-linear fits. ||||
7070
| `bs(...)` | Generates a B-Spline basis, allowing non-linear fits. ||||
71-
| `cr(...)` | Generates a natural cubic spline basis, allowing non-linear fits. ||||
72-
| `cc(...)` | Generates a cyclic cubic spline basis, allowing non-linear fits. ||||
71+
| `cs(...)` | Generates a natural cubic spline basis, allowing non-linear fits. ||||
72+
| `cr(...)` | Alias for `cs` above. ||||
73+
| `cc(...)` | Generates a cyclic cubic spline basis, allowing non-linear fits. ||||
7374
| `te(...)` | Generates a tensor product smooth. ||||
7475
| `hashed(...)` | Categorically encode a deterministic hash of a column. ||||
7576
| ... | Others? Contributions welcome! | ? | ? | ? |

docsite/docs/guides/splines.ipynb

Lines changed: 146 additions & 14 deletions
Large diffs are not rendered by default.

formulaic/transforms/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
from .basis_spline import basis_spline
66
from .contrasts import C, ContrastsRegistry, encode_contrasts
7+
from .cubic_spline import cyclic_cubic_spline, natural_cubic_spline
78
from .hashed import hashed
89
from .identity import identity
910
from .lag import lag
@@ -13,6 +14,9 @@
1314

1415
__all__ = [
1516
"basis_spline",
17+
"cubic_spline",
18+
"cyclic_cubic_spline",
19+
"natural_cubic_spline",
1620
"identity",
1721
"C",
1822
"encode_contrasts",
@@ -36,6 +40,9 @@
3640
"exp2": numpy.exp2,
3741
# Bespoke transforms
3842
"bs": basis_spline,
43+
"cc": cyclic_cubic_spline,
44+
"cr": natural_cubic_spline,
45+
"cs": natural_cubic_spline,
3946
"center": center,
4047
"lag": lag,
4148
"poly": poly,

0 commit comments

Comments
 (0)