liesel-gam 0.1.0a3__tar.gz → 0.1.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/.gitignore +2 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/PKG-INFO +9 -1
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/README.md +7 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/docs/source/index.rst +28 -1
- liesel_gam-0.1.1/docs/source/troubleshooting.md +21 -0
- liesel_gam-0.1.1/docs/source/troubleshooting.rst +2 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/docs/source/welcome.md +3 -3
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/pyproject.toml +1 -0
- liesel_gam-0.1.1/src/liesel_gam/__about__.py +1 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/src/liesel_gam/__init__.py +1 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/src/liesel_gam/basis.py +22 -16
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/src/liesel_gam/constraint.py +4 -3
- liesel_gam-0.1.1/src/liesel_gam/io.py +132 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/src/liesel_gam/term_builder.py +127 -12
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/uv.lock +2 -0
- liesel_gam-0.1.0a3/src/liesel_gam/__about__.py +0 -1
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/.gitattributes +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/.github/workflows/doctest.yml +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/.github/workflows/pre-commit.yml +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/.github/workflows/pypi.yml +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/.github/workflows/pytest-notebooks.yml +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/.github/workflows/pytest-pull.yml +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/.github/workflows/pytest.yml +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/.pre-commit-config.yaml +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/.readthedocs.yaml +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/LICENSE +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/docs/Makefile +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/docs/make.bat +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/docs/requirements.txt +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/docs/source/_static/custom.css +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/docs/source/_static/logo-light.png +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/docs/source/_templates/autosummary/attribute.rst +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/docs/source/_templates/autosummary/class.rst +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/docs/source/_templates/autosummary/function.rst +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/docs/source/_templates/autosummary/method.rst +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/docs/source/_templates/autosummary/module.rst +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/docs/source/conf.py +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/docs/source/notebooks_composite.rst +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/docs/source/notebooks_lin.rst +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/docs/source/notebooks_multivariate.rst +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/docs/source/notebooks_univariate.rst +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/docs/source/plots.png +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/img/plots.png +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/img/plots2.png +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/img/plots3.png +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/img/s1(x).png +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/src/liesel_gam/basis_builder.py +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/src/liesel_gam/category_mapping.py +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/src/liesel_gam/consolidate_bases.py +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/src/liesel_gam/demo_data.py +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/src/liesel_gam/dist.py +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/src/liesel_gam/experimental/__init__.py +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/src/liesel_gam/experimental/approx_bspline.py +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/src/liesel_gam/kernel.py +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/src/liesel_gam/names.py +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/src/liesel_gam/plots.py +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/src/liesel_gam/predictor.py +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/src/liesel_gam/registry.py +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/src/liesel_gam/summary.py +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/src/liesel_gam/term.py +0 -0
- {liesel_gam-0.1.0a3 → liesel_gam-0.1.1}/src/liesel_gam/var.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: liesel_gam
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.1
|
|
4
4
|
Summary: Functionality for Generalized Additive Models in Liesel
|
|
5
5
|
Author: Johannes Brachem
|
|
6
6
|
License-File: LICENSE
|
|
@@ -12,6 +12,7 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
12
12
|
Requires-Python: <3.14,>=3.13
|
|
13
13
|
Requires-Dist: formulaic>=1.2.1
|
|
14
14
|
Requires-Dist: liesel>=0.4.2
|
|
15
|
+
Requires-Dist: plotnine>=0.14.5
|
|
15
16
|
Requires-Dist: smoothcon>=0.0.9
|
|
16
17
|
Description-Content-Type: text/markdown
|
|
17
18
|
|
|
@@ -97,6 +98,13 @@ You can also install the development version from GitHub via pip:
|
|
|
97
98
|
pip install git+https://github.com/liesel-devs/liesel_gam.git
|
|
98
99
|
```
|
|
99
100
|
|
|
101
|
+
Since liesel-GAM interfaces with R via `ryp` under the hood,
|
|
102
|
+
you also need the R packages `{arrow}` and `{svglite}` to be available on your system:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
Rscript -e "install.packages(c('arrow', 'svglite'))"
|
|
106
|
+
```
|
|
107
|
+
|
|
100
108
|
## Contents
|
|
101
109
|
|
|
102
110
|
- [Short usage illustration](https://github.com/liesel-devs/liesel_gam?tab=readme-ov-file#illustrations)
|
|
@@ -80,6 +80,13 @@ You can also install the development version from GitHub via pip:
|
|
|
80
80
|
pip install git+https://github.com/liesel-devs/liesel_gam.git
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
+
Since liesel-GAM interfaces with R via `ryp` under the hood,
|
|
84
|
+
you also need the R packages `{arrow}` and `{svglite}` to be available on your system:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
Rscript -e "install.packages(c('arrow', 'svglite'))"
|
|
88
|
+
```
|
|
89
|
+
|
|
83
90
|
## Contents
|
|
84
91
|
|
|
85
92
|
- [Short usage illustration](https://github.com/liesel-devs/liesel_gam?tab=readme-ov-file#illustrations)
|
|
@@ -13,6 +13,14 @@ The library can be installed from PYPI:
|
|
|
13
13
|
|
|
14
14
|
$ pip install liesel_gam
|
|
15
15
|
|
|
16
|
+
Since liesel-GAM interfaces with R via ``ryp`` under the hood,
|
|
17
|
+
you also need the R packages ``{arrow}`` and ``{svglite}`` to be available on your system:
|
|
18
|
+
|
|
19
|
+
.. code:: bash
|
|
20
|
+
|
|
21
|
+
$ Rscript -e "install.packages(c('arrow', 'svglite'))"
|
|
22
|
+
|
|
23
|
+
|
|
16
24
|
Demo Notebooks
|
|
17
25
|
---------------
|
|
18
26
|
|
|
@@ -44,7 +52,7 @@ Relevant Literature
|
|
|
44
52
|
--------------------
|
|
45
53
|
|
|
46
54
|
Fahrmeier et al. (2013) is a textbook that introduces structured additive
|
|
47
|
-
regression concepts
|
|
55
|
+
regression concepts from the ground up. Wood (2017) is another seminal textbook on
|
|
48
56
|
generalized additive models. The R package mgcv provides many basis functions and
|
|
49
57
|
penalty matrices that we use in ``liesel_gam``.
|
|
50
58
|
|
|
@@ -70,6 +78,7 @@ regression.
|
|
|
70
78
|
|
|
71
79
|
|
|
72
80
|
|
|
81
|
+
|
|
73
82
|
API Reference
|
|
74
83
|
-------------
|
|
75
84
|
|
|
@@ -182,6 +191,16 @@ Other
|
|
|
182
191
|
~liesel_gam.demo_data_ta
|
|
183
192
|
~liesel_gam.LinearConstraintEVD
|
|
184
193
|
|
|
194
|
+
.. rubric:: In/Out
|
|
195
|
+
|
|
196
|
+
.. autosummary::
|
|
197
|
+
:toctree: generated
|
|
198
|
+
:caption: In/Out
|
|
199
|
+
:nosignatures:
|
|
200
|
+
|
|
201
|
+
~liesel_gam.io.read_bnd
|
|
202
|
+
~liesel_gam.io.polygon_is_closed
|
|
203
|
+
|
|
185
204
|
Experimental
|
|
186
205
|
***************
|
|
187
206
|
|
|
@@ -197,6 +216,14 @@ future.
|
|
|
197
216
|
~liesel_gam.experimental.BSplineApprox
|
|
198
217
|
|
|
199
218
|
|
|
219
|
+
.. toctree::
|
|
220
|
+
:hidden:
|
|
221
|
+
:caption: Help
|
|
222
|
+
:maxdepth: 1
|
|
223
|
+
|
|
224
|
+
troubleshooting
|
|
225
|
+
|
|
226
|
+
|
|
200
227
|
Acknowledgements and Funding
|
|
201
228
|
--------------------------------
|
|
202
229
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Troubleshooting
|
|
2
|
+
|
|
3
|
+
## Problems with interfacing to R / Problems with ryp
|
|
4
|
+
|
|
5
|
+
We use the Python package [`ryp`](https://github.com/Wainberg/ryp) to interface to R.
|
|
6
|
+
It uses the R installation pointed to by the environment variable `R_HOME`, or if
|
|
7
|
+
`R_HOME` is not defined by running `R HOME`. If you encounter problems with the
|
|
8
|
+
interface to R, it may be a solution to set the `R_HOME` environment variable manually.
|
|
9
|
+
|
|
10
|
+
Here, as an example, we set `R_HOME` to an R installation in a conda environment:
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
export R_HOME=conda/envs/r-renv/lib/R
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
In some cases, you may also need to explicitly append the R library to the environment
|
|
17
|
+
variable `LD_LIBRARY_PATH`:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
export LD_LIBRARY_PATH="$R_HOME/lib:$LD_LIBRARY_PATH"
|
|
21
|
+
```
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
This title is short and catchy, but does not convey the full range of models covered
|
|
2
|
-
by this library. We could also say:
|
|
2
|
+
by this Python library. We could also say:
|
|
3
3
|
|
|
4
4
|
- Bayesian Generalized Additive Models for **Location, Scale, and Shape** (and beyond)
|
|
5
5
|
- Bayesian **Structured Additive Distributional Regression**
|
|
@@ -15,8 +15,8 @@ formulas, known to many from the formula syntax in R.
|
|
|
15
15
|
|
|
16
16
|
Some technical highlights:
|
|
17
17
|
|
|
18
|
-
- Express Bayesian models as probabilistic graphical models via [liesel.model](https://github.com/liesel-devs/liesel)
|
|
19
|
-
- Build custom MCMC algorithms
|
|
18
|
+
- Express Bayesian models as probabilistic graphical models in Python via [liesel.model](https://github.com/liesel-devs/liesel)
|
|
19
|
+
- Build custom MCMC algorithms in Python, including Gibbs samplers, Hamiltonian Monte Carlo (HMC),
|
|
20
20
|
the iteratively reweighted least squares sampler (IWLS), and more via
|
|
21
21
|
[liesel.goose](https://github.com/liesel-devs/liesel)
|
|
22
22
|
- Speed up models using just-in-time compilation and automatic differentiation via [JAX](https://docs.jax.dev/en/latest/), since Liesel builds on JAX.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.1"
|
|
@@ -19,11 +19,11 @@ ArrayLike = jax.typing.ArrayLike
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
def make_callback(function, output_shape, dtype, m: int = 0):
|
|
22
|
-
if len(output_shape)
|
|
23
|
-
k = output_shape[-1]
|
|
22
|
+
k = output_shape[-1] if len(output_shape) else None
|
|
24
23
|
|
|
25
24
|
def fn(x, **basis_kwargs):
|
|
26
25
|
n = jnp.shape(jnp.atleast_1d(x))[0]
|
|
26
|
+
|
|
27
27
|
if len(output_shape) == 2:
|
|
28
28
|
shape = (n - m, k)
|
|
29
29
|
elif len(output_shape) == 1:
|
|
@@ -35,11 +35,17 @@ def make_callback(function, output_shape, dtype, m: int = 0):
|
|
|
35
35
|
"Return shape of 'basis_fn(value)' must"
|
|
36
36
|
f" have <= 2 dimensions, got {output_shape}"
|
|
37
37
|
)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
|
|
39
|
+
sig = jax.ShapeDtypeStruct(shape, dtype)
|
|
40
|
+
|
|
41
|
+
# ordered=True enforces sequencing of callback executions
|
|
42
|
+
return jax.experimental.io_callback(
|
|
43
|
+
function,
|
|
44
|
+
sig,
|
|
45
|
+
x,
|
|
46
|
+
ordered=True,
|
|
47
|
+
**basis_kwargs,
|
|
41
48
|
)
|
|
42
|
-
return result
|
|
43
49
|
|
|
44
50
|
return fn
|
|
45
51
|
|
|
@@ -55,12 +61,13 @@ class Basis(UserVar):
|
|
|
55
61
|
"""
|
|
56
62
|
General basis for a structured additive term.
|
|
57
63
|
|
|
58
|
-
The ``Basis`` class wraps
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
executed via a callback
|
|
62
|
-
potentially slow
|
|
63
|
-
|
|
64
|
+
The ``Basis`` class wraps an observation variable (or an array) and a
|
|
65
|
+
basis-generation function. It constructs an internal calculation node that produces
|
|
66
|
+
the basis (design) matrix by computing ``basis_fn(value)``. The basis function may
|
|
67
|
+
be executed via a callback, in which case it does not need to be jax-compatible.
|
|
68
|
+
This is the default, but it is potentially very slow, if the value of the basis
|
|
69
|
+
needs to be recomputed during estimation. We recommend it only for bases that remain
|
|
70
|
+
static during estimation.
|
|
64
71
|
|
|
65
72
|
Parameters
|
|
66
73
|
----------
|
|
@@ -139,10 +146,9 @@ class Basis(UserVar):
|
|
|
139
146
|
... )
|
|
140
147
|
Basis(name="B(x)")
|
|
141
148
|
|
|
142
|
-
Implementing a fixed basis matrix (without using the basis function). This is
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
predictions.
|
|
149
|
+
Implementing a fixed basis matrix (without using the basis function). This is not
|
|
150
|
+
recommended, because it means you cannot simply supply new covariate values to
|
|
151
|
+
:meth:`liesel.model.Model.predict` for evaluating the basis matrix for predictions.
|
|
146
152
|
|
|
147
153
|
>>> from liesel.contrib.splines import equidistant_knots, basis_matrix
|
|
148
154
|
>>> import liesel_gam as gam
|
|
@@ -82,11 +82,12 @@ class LinearConstraintEVD:
|
|
|
82
82
|
AtA = A.T @ A
|
|
83
83
|
evals, evecs = jnp.linalg.eigh(AtA)
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
signs = jnp.sign(evecs[0, :])
|
|
86
|
+
signs = jnp.where(signs == 0, 1.0, signs)
|
|
87
|
+
evecs = evecs * signs
|
|
87
88
|
|
|
88
89
|
rank = jnp.linalg.matrix_rank(AtA)
|
|
89
|
-
Abar = evecs[:-rank]
|
|
90
|
+
Abar = evecs[:, :-rank].T
|
|
90
91
|
|
|
91
92
|
A_stacked = jnp.r_[A, Abar]
|
|
92
93
|
C_stacked = jnp.linalg.inv(A_stacked)
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
import numpy as np
|
|
5
|
+
|
|
6
|
+
logger = logging.getLogger(__name__)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def read_bnd(
|
|
10
|
+
filename: str | Path,
|
|
11
|
+
delimiter: str = ",",
|
|
12
|
+
) -> dict[str, np.typing.NDArray]:
|
|
13
|
+
"""
|
|
14
|
+
Reads a .bnd file with geographical information, returns a polys dictionary.
|
|
15
|
+
|
|
16
|
+
Parameters
|
|
17
|
+
----------
|
|
18
|
+
filename
|
|
19
|
+
Filename.
|
|
20
|
+
delimiter
|
|
21
|
+
Delimiter
|
|
22
|
+
|
|
23
|
+
Notes
|
|
24
|
+
-----
|
|
25
|
+
The expected file format looks like this::
|
|
26
|
+
|
|
27
|
+
"A", 66
|
|
28
|
+
25.6422, -17.8037
|
|
29
|
+
25.6477, -17.7607
|
|
30
|
+
...
|
|
31
|
+
"B", 192
|
|
32
|
+
27.276, -17.0096
|
|
33
|
+
27.6848, -17.1684
|
|
34
|
+
...
|
|
35
|
+
|
|
36
|
+
Where the lines ``"A",66`` and ``"B",192`` are header lines that indicate the region
|
|
37
|
+
label, and the number of following lines that define the polygon for the respective
|
|
38
|
+
region. In this case, the region labelled ``"A"`` is defined by the following 66
|
|
39
|
+
lines, and the region labelled ``"B"`` is defined by the following 192 lines.
|
|
40
|
+
"""
|
|
41
|
+
polygons = {}
|
|
42
|
+
|
|
43
|
+
with open(filename) as f:
|
|
44
|
+
while True:
|
|
45
|
+
header = f.readline()
|
|
46
|
+
if not header:
|
|
47
|
+
break # EOF
|
|
48
|
+
|
|
49
|
+
header = header.strip()
|
|
50
|
+
if not header:
|
|
51
|
+
continue # skip empty lines
|
|
52
|
+
|
|
53
|
+
parts = header.split(delimiter)
|
|
54
|
+
if len(parts) != 2:
|
|
55
|
+
raise ValueError(f"Invalid header line: {header}")
|
|
56
|
+
|
|
57
|
+
label, n_points = parts
|
|
58
|
+
label = label.strip().strip("\"'")
|
|
59
|
+
|
|
60
|
+
try:
|
|
61
|
+
n_points_int = int(n_points)
|
|
62
|
+
except ValueError as e:
|
|
63
|
+
raise ValueError(f"Invalid number of points in header: {header}") from e
|
|
64
|
+
|
|
65
|
+
coords = []
|
|
66
|
+
for _ in range(n_points_int):
|
|
67
|
+
line = f.readline()
|
|
68
|
+
if not line:
|
|
69
|
+
raise ValueError("Unexpected end of file while reading coordinates")
|
|
70
|
+
|
|
71
|
+
line = line.strip()
|
|
72
|
+
if not line:
|
|
73
|
+
raise ValueError("Unexpected empty line while reading coordinates")
|
|
74
|
+
|
|
75
|
+
xy = line.split(delimiter)
|
|
76
|
+
if len(xy) != 2:
|
|
77
|
+
raise ValueError(f"Invalid coordinate line: {line}")
|
|
78
|
+
|
|
79
|
+
x, y = map(float, xy)
|
|
80
|
+
coords.append([x, y])
|
|
81
|
+
|
|
82
|
+
polygons[label] = np.array(coords, dtype=float)
|
|
83
|
+
|
|
84
|
+
for label, poly in polygons.items():
|
|
85
|
+
if not polygon_is_closed(poly):
|
|
86
|
+
msg = (
|
|
87
|
+
f"Polygon of region with label '{label}' does not appear to be closed "
|
|
88
|
+
"(first and last point are not equal)."
|
|
89
|
+
)
|
|
90
|
+
logger.warning(msg)
|
|
91
|
+
|
|
92
|
+
return polygons
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def polygon_is_closed(
|
|
96
|
+
poly: np.typing.ArrayLike,
|
|
97
|
+
*,
|
|
98
|
+
atol: float = 1e-12,
|
|
99
|
+
rtol: float = 0.0,
|
|
100
|
+
require_min_points: bool = True,
|
|
101
|
+
) -> bool:
|
|
102
|
+
"""
|
|
103
|
+
Validate that a polygon is closed: first vertex equals last vertex (within
|
|
104
|
+
tolerance).
|
|
105
|
+
|
|
106
|
+
Parameters
|
|
107
|
+
----------
|
|
108
|
+
poly : array-like, shape (n, 2)
|
|
109
|
+
Polygon vertices.
|
|
110
|
+
atol, rtol : float
|
|
111
|
+
Absolute / relative tolerances used by np.allclose.
|
|
112
|
+
require_min_points : bool
|
|
113
|
+
If True, require at least 4 points for a closed polygon (first==last + >=3
|
|
114
|
+
distinct vertices).
|
|
115
|
+
|
|
116
|
+
Returns
|
|
117
|
+
-------
|
|
118
|
+
True if closed, else False.
|
|
119
|
+
"""
|
|
120
|
+
arr = np.asarray(poly, dtype=float)
|
|
121
|
+
|
|
122
|
+
if arr.ndim != 2 or arr.shape[1] != 2:
|
|
123
|
+
raise ValueError(f"Expected shape (n, 2), got {arr.shape}")
|
|
124
|
+
|
|
125
|
+
n = arr.shape[0]
|
|
126
|
+
if n == 0:
|
|
127
|
+
return False
|
|
128
|
+
|
|
129
|
+
if require_min_points and n < 4:
|
|
130
|
+
return False
|
|
131
|
+
|
|
132
|
+
return np.allclose(arr[0], arr[-1], atol=atol, rtol=rtol)
|
|
@@ -62,7 +62,10 @@ class TermBuilder:
|
|
|
62
62
|
Defines the default inference specification for terms created by this builder.
|
|
63
63
|
Note that this inference is only used for the coefficient variables
|
|
64
64
|
of the terms created by this builder (:attr:`.StrctTerm.coef`), *not* for the
|
|
65
|
-
scale variables (:attr:`.StrctTerm.scale`).
|
|
65
|
+
scale variables (:attr:`.StrctTerm.scale`). The default
|
|
66
|
+
``gs.MCMCSpec(gs.IWLSKernel.untuned)`` is an iteratively-reweighted least
|
|
67
|
+
squares kernel without step size tuning, see
|
|
68
|
+
:meth:`liesel.goose.IWLSKernel.untuned`.
|
|
66
69
|
default_scale_fn
|
|
67
70
|
A function or :class:`.VarIGPrior` object that defines the default scale
|
|
68
71
|
for structured additive terms initialized by this builder. If this is a
|
|
@@ -72,11 +75,13 @@ class TermBuilder:
|
|
|
72
75
|
``var ~ InverseGamma(concentration, scale)``, with concentration and scale
|
|
73
76
|
given by the :class:`.VarIGPrior` object. For most terms, this
|
|
74
77
|
will mean that a fitting Gibbs sampler can be automatically set up for
|
|
75
|
-
``var``. The exceptions to this rule are :meth:`.
|
|
78
|
+
``var``. The exceptions to this rule are :meth:`.tf` and
|
|
76
79
|
:meth:`.tx`. Note that, if you supply a custom default scale function, you
|
|
77
80
|
should make sure that the ``inference`` attribute of your custom scale
|
|
78
81
|
is defined, otherwise your custom scale may not be included in MCMC
|
|
79
|
-
sampling.
|
|
82
|
+
sampling. The default is ``VarIGPrior(1.0, 0.005)``, which leads to an
|
|
83
|
+
inverse Gamma prior on the level of the variance parameter, i.e.
|
|
84
|
+
:math:`\tau^2 \sim \operatorname{InverseGamma}(1.0, 0.005)`.
|
|
80
85
|
|
|
81
86
|
See Also
|
|
82
87
|
--------
|
|
@@ -441,8 +446,10 @@ class TermBuilder:
|
|
|
441
446
|
prior.
|
|
442
447
|
inference
|
|
443
448
|
An optional :class:`liesel.goose.MCMCSpec` instance (or other valid
|
|
444
|
-
inference object).
|
|
445
|
-
|
|
449
|
+
inference object).
|
|
450
|
+
The default (``"default"``) uses the :class:`.TermBuilder`'s default
|
|
451
|
+
inference specification defined during initialization. Please refer to
|
|
452
|
+
the TermBuilder documentation for more information.
|
|
446
453
|
context
|
|
447
454
|
Dictionary of additional Python objects that should be made available to
|
|
448
455
|
formulaic when constructing the design matrix. Gets passed to
|
|
@@ -571,13 +578,31 @@ class TermBuilder:
|
|
|
571
578
|
formula
|
|
572
579
|
Right-hand side of a model formula, as understood by formulaic_. Most of
|
|
573
580
|
formulaic's grammar_ is supported. See notes for details.
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
581
|
+
scale
|
|
582
|
+
Scale parameter passed to the coefficient prior, :attr:`.StrctTerm.scale`.
|
|
583
|
+
|
|
584
|
+
- If ``"default"``, the scale will be initialized according to the default
|
|
585
|
+
scale function defined for this :class:`.TermBuilder` instance.
|
|
586
|
+
Please refer to the TermBuilder documentation for more information.
|
|
587
|
+
- If you pass a ``float``, this will be taken as the constant value of
|
|
588
|
+
the scale, and the scale will not be estimated as part of the model
|
|
589
|
+
without further action.
|
|
590
|
+
- If you pass a :class:`liesel.model.Var`, this will be used as the scale.
|
|
591
|
+
Make sure to define the ``inference`` attribute of your custom
|
|
592
|
+
scale variable (or a latent, transformed version of it).
|
|
593
|
+
- If you pass a :class:`.VarIGPrior`, a scale variable will be set up for
|
|
594
|
+
you using :class:`.ScaleIG`. This means, the scale will be
|
|
595
|
+
:math:`\tau`, with an iverse Gamma prior on its square, i.e.
|
|
596
|
+
:math:`\tau^2 \\sim \\operatorname{InverseGamma}(a, b)`, where a and b
|
|
597
|
+
are taken from the :class:`.VarIGPrior` object. A fitting Gibbs kernel
|
|
598
|
+
will be set up automatically to sample :math:`\tau^2` in this case,
|
|
599
|
+
see :class:`.ScaleIG` for details.
|
|
577
600
|
inference
|
|
578
601
|
An optional :class:`liesel.goose.MCMCSpec` instance (or other valid
|
|
579
|
-
inference object).
|
|
580
|
-
|
|
602
|
+
inference object).
|
|
603
|
+
The default (``"default"``) uses the :class:`.TermBuilder`'s default
|
|
604
|
+
inference specification defined during initialization. Please refer to
|
|
605
|
+
the TermBuilder documentation for more information.
|
|
581
606
|
context
|
|
582
607
|
Dictionary of additional Python objects that should be made available to
|
|
583
608
|
formulaic when constructing the design matrix. Gets passed to
|
|
@@ -692,6 +717,9 @@ class TermBuilder:
|
|
|
692
717
|
scale
|
|
693
718
|
Scale parameter passed to the coefficient prior, :attr:`.StrctTerm.scale`.
|
|
694
719
|
|
|
720
|
+
- If ``"default"``, the scale will be initialized according to the default
|
|
721
|
+
scale function defined for this :class:`.TermBuilder` instance.
|
|
722
|
+
Please refer to the TermBuilder documentation for more information.
|
|
695
723
|
- If you pass a ``float``, this will be taken as the constant value of
|
|
696
724
|
the scale, and the scale will not be estimated as part of the model
|
|
697
725
|
without further action.
|
|
@@ -710,6 +738,9 @@ class TermBuilder:
|
|
|
710
738
|
Note that this inference is only used for the coefficient variables
|
|
711
739
|
of the terms created by this builder (:attr:`.StrctTerm.coef`), *not* for
|
|
712
740
|
the scale variables (:attr:`.StrctTerm.scale`).
|
|
741
|
+
The default (``"default"``) uses the :class:`.TermBuilder`'s default
|
|
742
|
+
inference specification defined during initialization. Please refer to
|
|
743
|
+
the TermBuilder documentation for more information.
|
|
713
744
|
penalty_order
|
|
714
745
|
Order of the penalty.
|
|
715
746
|
knots
|
|
@@ -816,6 +847,9 @@ class TermBuilder:
|
|
|
816
847
|
scale
|
|
817
848
|
Scale parameter passed to the coefficient prior, :attr:`.StrctTerm.scale`.
|
|
818
849
|
|
|
850
|
+
- If ``"default"``, the scale will be initialized according to the default
|
|
851
|
+
scale function defined for this :class:`.TermBuilder` instance.
|
|
852
|
+
Please refer to the TermBuilder documentation for more information.
|
|
819
853
|
- If you pass a ``float``, this will be taken as the constant value of
|
|
820
854
|
the scale, and the scale will not be estimated as part of the model
|
|
821
855
|
without further action.
|
|
@@ -834,6 +868,9 @@ class TermBuilder:
|
|
|
834
868
|
Note that this inference is only used for the coefficient variables
|
|
835
869
|
of the terms created by this builder (:attr:`.StrctTerm.coef`), *not* for
|
|
836
870
|
the scale variables (:attr:`.StrctTerm.scale`).
|
|
871
|
+
The default (``"default"``) uses the :class:`.TermBuilder`'s default
|
|
872
|
+
inference specification defined during initialization. Please refer to
|
|
873
|
+
the TermBuilder documentation for more information.
|
|
837
874
|
penalty_order
|
|
838
875
|
Order of the penalty.
|
|
839
876
|
knots
|
|
@@ -940,6 +977,9 @@ class TermBuilder:
|
|
|
940
977
|
scale
|
|
941
978
|
Scale parameter passed to the coefficient prior, :attr:`.StrctTerm.scale`.
|
|
942
979
|
|
|
980
|
+
- If ``"default"``, the scale will be initialized according to the default
|
|
981
|
+
scale function defined for this :class:`.TermBuilder` instance.
|
|
982
|
+
Please refer to the TermBuilder documentation for more information.
|
|
943
983
|
- If you pass a ``float``, this will be taken as the constant value of
|
|
944
984
|
the scale, and the scale will not be estimated as part of the model
|
|
945
985
|
without further action.
|
|
@@ -958,6 +998,9 @@ class TermBuilder:
|
|
|
958
998
|
Note that this inference is only used for the coefficient variables
|
|
959
999
|
of the terms created by this builder (:attr:`.StrctTerm.coef`), *not* for
|
|
960
1000
|
the scale variables (:attr:`.StrctTerm.scale`).
|
|
1001
|
+
The default (``"default"``) uses the :class:`.TermBuilder`'s default
|
|
1002
|
+
inference specification defined during initialization. Please refer to
|
|
1003
|
+
the TermBuilder documentation for more information.
|
|
961
1004
|
penalty_order
|
|
962
1005
|
Order of the penalty.
|
|
963
1006
|
knots
|
|
@@ -1066,6 +1109,9 @@ class TermBuilder:
|
|
|
1066
1109
|
scale
|
|
1067
1110
|
Scale parameter passed to the coefficient prior, :attr:`.StrctTerm.scale`.
|
|
1068
1111
|
|
|
1112
|
+
- If ``"default"``, the scale will be initialized according to the default
|
|
1113
|
+
scale function defined for this :class:`.TermBuilder` instance.
|
|
1114
|
+
Please refer to the TermBuilder documentation for more information.
|
|
1069
1115
|
- If you pass a ``float``, this will be taken as the constant value of
|
|
1070
1116
|
the scale, and the scale will not be estimated as part of the model
|
|
1071
1117
|
without further action.
|
|
@@ -1084,6 +1130,9 @@ class TermBuilder:
|
|
|
1084
1130
|
Note that this inference is only used for the coefficient variables
|
|
1085
1131
|
of the terms created by this builder (:attr:`.StrctTerm.coef`), *not* for
|
|
1086
1132
|
the scale variables (:attr:`.StrctTerm.scale`).
|
|
1133
|
+
The default (``"default"``) uses the :class:`.TermBuilder`'s default
|
|
1134
|
+
inference specification defined during initialization. Please refer to
|
|
1135
|
+
the TermBuilder documentation for more information.
|
|
1087
1136
|
basis_degree
|
|
1088
1137
|
Degree of the polynomials used in the B-spline basis function. Default is 3
|
|
1089
1138
|
for cubic B-splines.
|
|
@@ -1196,6 +1245,9 @@ class TermBuilder:
|
|
|
1196
1245
|
scale
|
|
1197
1246
|
Scale parameter passed to the coefficient prior, :attr:`.StrctTerm.scale`.
|
|
1198
1247
|
|
|
1248
|
+
- If ``"default"``, the scale will be initialized according to the default
|
|
1249
|
+
scale function defined for this :class:`.TermBuilder` instance.
|
|
1250
|
+
Please refer to the TermBuilder documentation for more information.
|
|
1199
1251
|
- If you pass a ``float``, this will be taken as the constant value of
|
|
1200
1252
|
the scale, and the scale will not be estimated as part of the model
|
|
1201
1253
|
without further action.
|
|
@@ -1214,6 +1266,9 @@ class TermBuilder:
|
|
|
1214
1266
|
Note that this inference is only used for the coefficient variables
|
|
1215
1267
|
of the terms created by this builder (:attr:`.StrctTerm.coef`), *not* for
|
|
1216
1268
|
the scale variables (:attr:`.StrctTerm.scale`).
|
|
1269
|
+
The default (``"default"``) uses the :class:`.TermBuilder`'s default
|
|
1270
|
+
inference specification defined during initialization. Please refer to
|
|
1271
|
+
the TermBuilder documentation for more information.
|
|
1217
1272
|
basis_degree
|
|
1218
1273
|
Degree of the polynomials used in the B-spline basis function. Default is 3
|
|
1219
1274
|
for cubic B-splines.
|
|
@@ -1338,6 +1393,9 @@ class TermBuilder:
|
|
|
1338
1393
|
scale
|
|
1339
1394
|
Scale parameter passed to the coefficient prior, :attr:`.StrctTerm.scale`.
|
|
1340
1395
|
|
|
1396
|
+
- If ``"default"``, the scale will be initialized according to the default
|
|
1397
|
+
scale function defined for this :class:`.TermBuilder` instance.
|
|
1398
|
+
Please refer to the TermBuilder documentation for more information.
|
|
1341
1399
|
- If you pass a ``float``, this will be taken as the constant value of
|
|
1342
1400
|
the scale, and the scale will not be estimated as part of the model
|
|
1343
1401
|
without further action.
|
|
@@ -1356,6 +1414,9 @@ class TermBuilder:
|
|
|
1356
1414
|
Note that this inference is only used for the coefficient variables
|
|
1357
1415
|
of the terms created by this builder (:attr:`.StrctTerm.coef`), *not* for
|
|
1358
1416
|
the scale variables (:attr:`.StrctTerm.scale`).
|
|
1417
|
+
The default (``"default"``) uses the :class:`.TermBuilder`'s default
|
|
1418
|
+
inference specification defined during initialization. Please refer to
|
|
1419
|
+
the TermBuilder documentation for more information.
|
|
1359
1420
|
basis_degree
|
|
1360
1421
|
Degree of the polynomials used in the B-spline basis function. Default is 3
|
|
1361
1422
|
for cubic B-splines.
|
|
@@ -1477,6 +1538,9 @@ class TermBuilder:
|
|
|
1477
1538
|
scale
|
|
1478
1539
|
Scale parameter passed to the coefficient prior, :attr:`.StrctTerm.scale`.
|
|
1479
1540
|
|
|
1541
|
+
- If ``"default"``, the scale will be initialized according to the default
|
|
1542
|
+
scale function defined for this :class:`.TermBuilder` instance.
|
|
1543
|
+
Please refer to the TermBuilder documentation for more information.
|
|
1480
1544
|
- If you pass a ``float``, this will be taken as the constant value of
|
|
1481
1545
|
the scale, and the scale will not be estimated as part of the model
|
|
1482
1546
|
without further action.
|
|
@@ -1495,6 +1559,9 @@ class TermBuilder:
|
|
|
1495
1559
|
Note that this inference is only used for the coefficient variables
|
|
1496
1560
|
of the terms created by this builder (:attr:`.StrctTerm.coef`), *not* for
|
|
1497
1561
|
the scale variables (:attr:`.StrctTerm.scale`).
|
|
1562
|
+
The default (``"default"``) uses the :class:`.TermBuilder`'s default
|
|
1563
|
+
inference specification defined during initialization. Please refer to
|
|
1564
|
+
the TermBuilder documentation for more information.
|
|
1498
1565
|
basis_degree
|
|
1499
1566
|
Degree of the polynomials used in the B-spline basis function. Default is 3
|
|
1500
1567
|
for cubic B-splines.
|
|
@@ -1602,6 +1669,9 @@ class TermBuilder:
|
|
|
1602
1669
|
scale
|
|
1603
1670
|
Scale parameter passed to the coefficient prior, :attr:`.StrctTerm.scale`.
|
|
1604
1671
|
|
|
1672
|
+
- If ``"default"``, the scale will be initialized according to the default
|
|
1673
|
+
scale function defined for this :class:`.TermBuilder` instance.
|
|
1674
|
+
Please refer to the TermBuilder documentation for more information.
|
|
1605
1675
|
- If you pass a ``float``, this will be taken as the constant value of
|
|
1606
1676
|
the scale, and the scale will not be estimated as part of the model
|
|
1607
1677
|
without further action.
|
|
@@ -1620,6 +1690,9 @@ class TermBuilder:
|
|
|
1620
1690
|
Note that this inference is only used for the coefficient variables
|
|
1621
1691
|
of the terms created by this builder (:attr:`.StrctTerm.coef`), *not* for
|
|
1622
1692
|
the scale variables (:attr:`.StrctTerm.scale`).
|
|
1693
|
+
The default (``"default"``) uses the :class:`.TermBuilder`'s default
|
|
1694
|
+
inference specification defined during initialization. Please refer to
|
|
1695
|
+
the TermBuilder documentation for more information.
|
|
1623
1696
|
penalty
|
|
1624
1697
|
Custom penalty matrix to use. Default is an iid penalty.
|
|
1625
1698
|
factor_scale
|
|
@@ -1717,6 +1790,9 @@ class TermBuilder:
|
|
|
1717
1790
|
scale
|
|
1718
1791
|
Scale parameter passed to the coefficient prior, :attr:`.StrctTerm.scale`.
|
|
1719
1792
|
|
|
1793
|
+
- If ``"default"``, the scale will be initialized according to the default
|
|
1794
|
+
scale function defined for this :class:`.TermBuilder` instance.
|
|
1795
|
+
Please refer to the TermBuilder documentation for more information.
|
|
1720
1796
|
- If you pass a ``float``, this will be taken as the constant value of
|
|
1721
1797
|
the scale, and the scale will not be estimated as part of the model
|
|
1722
1798
|
without further action.
|
|
@@ -1735,6 +1811,9 @@ class TermBuilder:
|
|
|
1735
1811
|
Note that this inference is only used for the coefficient variables
|
|
1736
1812
|
of the terms created by this builder (:attr:`.StrctTerm.coef`), *not* for
|
|
1737
1813
|
the scale variables (:attr:`.StrctTerm.scale`).
|
|
1814
|
+
The default (``"default"``) uses the :class:`.TermBuilder`'s default
|
|
1815
|
+
inference specification defined during initialization. Please refer to
|
|
1816
|
+
the TermBuilder documentation for more information.
|
|
1738
1817
|
penalty
|
|
1739
1818
|
Custom penalty matrix to use. Default is an iid penalty.
|
|
1740
1819
|
factor_scale
|
|
@@ -1920,6 +1999,9 @@ class TermBuilder:
|
|
|
1920
1999
|
scale
|
|
1921
2000
|
Scale parameter passed to the coefficient prior, :attr:`.StrctTerm.scale`.
|
|
1922
2001
|
|
|
2002
|
+
- If ``"default"``, the scale will be initialized according to the default
|
|
2003
|
+
scale function defined for this :class:`.TermBuilder` instance.
|
|
2004
|
+
Please refer to the TermBuilder documentation for more information.
|
|
1923
2005
|
- If you pass a ``float``, this will be taken as the constant value of
|
|
1924
2006
|
the scale, and the scale will not be estimated as part of the model
|
|
1925
2007
|
without further action.
|
|
@@ -1938,6 +2020,9 @@ class TermBuilder:
|
|
|
1938
2020
|
Note that this inference is only used for the coefficient variables
|
|
1939
2021
|
of the terms created by this builder (:attr:`.StrctTerm.coef`), *not* for
|
|
1940
2022
|
the scale variables (:attr:`.StrctTerm.scale`).
|
|
2023
|
+
The default (``"default"``) uses the :class:`.TermBuilder`'s default
|
|
2024
|
+
inference specification defined during initialization. Please refer to
|
|
2025
|
+
the TermBuilder documentation for more information.
|
|
1941
2026
|
polys
|
|
1942
2027
|
Dictionary of arrays. The keys of the dict are the region labels. The
|
|
1943
2028
|
corresponding values define the region by defining polygons. The
|
|
@@ -2095,6 +2180,9 @@ class TermBuilder:
|
|
|
2095
2180
|
scale
|
|
2096
2181
|
Scale parameter passed to the coefficient prior, :attr:`.StrctTerm.scale`.
|
|
2097
2182
|
|
|
2183
|
+
- If ``"default"``, the scale will be initialized according to the default
|
|
2184
|
+
scale function defined for this :class:`.TermBuilder` instance.
|
|
2185
|
+
Please refer to the TermBuilder documentation for more information.
|
|
2098
2186
|
- If you pass a ``float``, this will be taken as the constant value of
|
|
2099
2187
|
the scale, and the scale will not be estimated as part of the model
|
|
2100
2188
|
without further action.
|
|
@@ -2113,6 +2201,9 @@ class TermBuilder:
|
|
|
2113
2201
|
Note that this inference is only used for the coefficient variables
|
|
2114
2202
|
of the terms created by this builder (:attr:`.StrctTerm.coef`), *not* for
|
|
2115
2203
|
the scale variables (:attr:`.StrctTerm.scale`).
|
|
2204
|
+
The default (``"default"``) uses the :class:`.TermBuilder`'s default
|
|
2205
|
+
inference specification defined during initialization. Please refer to
|
|
2206
|
+
the TermBuilder documentation for more information.
|
|
2116
2207
|
use_callback
|
|
2117
2208
|
If *True*, the basis function is evaluated using a Python callback,
|
|
2118
2209
|
which means that it does not have to be jit-compatible via JAX. This also
|
|
@@ -2239,6 +2330,9 @@ class TermBuilder:
|
|
|
2239
2330
|
scale
|
|
2240
2331
|
Scale parameter passed to the coefficient prior, :attr:`.StrctTerm.scale`.
|
|
2241
2332
|
|
|
2333
|
+
- If ``"default"``, the scale will be initialized according to the default
|
|
2334
|
+
scale function defined for this :class:`.TermBuilder` instance.
|
|
2335
|
+
Please refer to the TermBuilder documentation for more information.
|
|
2242
2336
|
- If you pass a ``float``, this will be taken as the constant value of
|
|
2243
2337
|
the scale, and the scale will not be estimated as part of the model
|
|
2244
2338
|
without further action.
|
|
@@ -2257,6 +2351,9 @@ class TermBuilder:
|
|
|
2257
2351
|
Note that this inference is only used for the coefficient variables
|
|
2258
2352
|
of the terms created by this builder (:attr:`.StrctTerm.coef`), *not* for
|
|
2259
2353
|
the scale variables (:attr:`.StrctTerm.scale`).
|
|
2354
|
+
The default (``"default"``) uses the :class:`.TermBuilder`'s default
|
|
2355
|
+
inference specification defined during initialization. Please refer to
|
|
2356
|
+
the TermBuilder documentation for more information.
|
|
2260
2357
|
kernel_name
|
|
2261
2358
|
Selects the kernel / covariance function to use.
|
|
2262
2359
|
linear_trend
|
|
@@ -2367,6 +2464,9 @@ class TermBuilder:
|
|
|
2367
2464
|
scale
|
|
2368
2465
|
Scale parameter passed to the coefficient prior, :attr:`.StrctTerm.scale`.
|
|
2369
2466
|
|
|
2467
|
+
- If ``"default"``, the scale will be initialized according to the default
|
|
2468
|
+
scale function defined for this :class:`.TermBuilder` instance.
|
|
2469
|
+
Please refer to the TermBuilder documentation for more information.
|
|
2370
2470
|
- If you pass a ``float``, this will be taken as the constant value of
|
|
2371
2471
|
the scale, and the scale will not be estimated as part of the model
|
|
2372
2472
|
without further action.
|
|
@@ -2385,6 +2485,9 @@ class TermBuilder:
|
|
|
2385
2485
|
Note that this inference is only used for the coefficient variables
|
|
2386
2486
|
of the terms created by this builder (:attr:`.StrctTerm.coef`), *not* for
|
|
2387
2487
|
the scale variables (:attr:`.StrctTerm.scale`).
|
|
2488
|
+
The default (``"default"``) uses the :class:`.TermBuilder`'s default
|
|
2489
|
+
inference specification defined during initialization. Please refer to
|
|
2490
|
+
the TermBuilder documentation for more information.
|
|
2388
2491
|
penalty_order
|
|
2389
2492
|
Order of the penalty. Quote from mgcv: "The default is to set this to the
|
|
2390
2493
|
smallest value satisfying ``2*penalty_order > d+1`` where ``d`` is the
|
|
@@ -2494,6 +2597,9 @@ class TermBuilder:
|
|
|
2494
2597
|
scale
|
|
2495
2598
|
Scale parameter passed to the coefficient prior, :attr:`.StrctTerm.scale`.
|
|
2496
2599
|
|
|
2600
|
+
- If ``"default"``, the scale will be initialized according to the default
|
|
2601
|
+
scale function defined for this :class:`.TermBuilder` instance.
|
|
2602
|
+
Please refer to the TermBuilder documentation for more information.
|
|
2497
2603
|
- If you pass a ``float``, this will be taken as the constant value of
|
|
2498
2604
|
the scale, and the scale will not be estimated as part of the model
|
|
2499
2605
|
without further action.
|
|
@@ -2512,6 +2618,9 @@ class TermBuilder:
|
|
|
2512
2618
|
Note that this inference is only used for the coefficient variables
|
|
2513
2619
|
of the terms created by this builder (:attr:`.StrctTerm.coef`), *not* for
|
|
2514
2620
|
the scale variables (:attr:`.StrctTerm.scale`).
|
|
2621
|
+
The default (``"default"``) uses the :class:`.TermBuilder`'s default
|
|
2622
|
+
inference specification defined during initialization. Please refer to
|
|
2623
|
+
the TermBuilder documentation for more information.
|
|
2515
2624
|
penalty_order
|
|
2516
2625
|
Order of the penalty. Quote from mgcv: "The default is to set this to the
|
|
2517
2626
|
smallest value satisfying ``2*penalty_order > d+1`` where ``d`` is the
|
|
@@ -2695,7 +2804,7 @@ class TermBuilder:
|
|
|
2695
2804
|
Includes only the tensor product interaction. Corresponds to ``mgcv::ti``.
|
|
2696
2805
|
|
|
2697
2806
|
.. warning::
|
|
2698
|
-
This method
|
|
2807
|
+
This method removes any default gibbs samplers and replaces them with
|
|
2699
2808
|
``scales_inference`` on log level, since the full conditional for the
|
|
2700
2809
|
variance parameters is not known in closed form for an anisotropic
|
|
2701
2810
|
tensor product.
|
|
@@ -2711,6 +2820,9 @@ class TermBuilder:
|
|
|
2711
2820
|
in the notation used in :class:`.StrctTensorProdTerm`.
|
|
2712
2821
|
inference
|
|
2713
2822
|
Inference specification for this term's coefficient.
|
|
2823
|
+
The default (``"default"``) uses the :class:`.TermBuilder`'s default
|
|
2824
|
+
inference specification defined during initialization. Please refer to
|
|
2825
|
+
the TermBuilder documentation for more information.
|
|
2714
2826
|
scales_inference
|
|
2715
2827
|
If ``"default"``, uses the default inference passed to the TermBuilder
|
|
2716
2828
|
upon initialization.
|
|
@@ -2885,7 +2997,7 @@ class TermBuilder:
|
|
|
2885
2997
|
Corresponds to ``mgcv::te``.
|
|
2886
2998
|
|
|
2887
2999
|
.. warning::
|
|
2888
|
-
This method
|
|
3000
|
+
This method removes any default gibbs samplers and replaces them with
|
|
2889
3001
|
``scales_inference`` on log level, since the full conditional for the
|
|
2890
3002
|
variance parameters is not known in closed form for an anisotropic
|
|
2891
3003
|
tensor product.
|
|
@@ -2901,6 +3013,9 @@ class TermBuilder:
|
|
|
2901
3013
|
in the notation used in :class:`.StrctTensorProdTerm`.
|
|
2902
3014
|
inference
|
|
2903
3015
|
Inference specification for this term's coefficient.
|
|
3016
|
+
The default (``"default"``) uses the :class:`.TermBuilder`'s default
|
|
3017
|
+
inference specification defined during initialization. Please refer to
|
|
3018
|
+
the TermBuilder documentation for more information.
|
|
2904
3019
|
scales_inference
|
|
2905
3020
|
If ``"default"``, uses the default inference passed to the TermBuilder
|
|
2906
3021
|
upon initialization.
|
|
@@ -853,6 +853,7 @@ source = { editable = "." }
|
|
|
853
853
|
dependencies = [
|
|
854
854
|
{ name = "formulaic" },
|
|
855
855
|
{ name = "liesel" },
|
|
856
|
+
{ name = "plotnine" },
|
|
856
857
|
{ name = "smoothcon" },
|
|
857
858
|
]
|
|
858
859
|
|
|
@@ -878,6 +879,7 @@ dev = [
|
|
|
878
879
|
requires-dist = [
|
|
879
880
|
{ name = "formulaic", specifier = ">=1.2.1" },
|
|
880
881
|
{ name = "liesel", specifier = ">=0.4.2" },
|
|
882
|
+
{ name = "plotnine", specifier = ">=0.14.5" },
|
|
881
883
|
{ name = "smoothcon", specifier = ">=0.0.9" },
|
|
882
884
|
]
|
|
883
885
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.1.0-a3"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|