liesel-gam 0.0.4__py3-none-any.whl → 0.0.6a4__py3-none-any.whl

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.
@@ -1,160 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: liesel_gam
3
- Version: 0.0.4
4
- Summary: Functionality for Generalized Additive Models in Liesel
5
- Author: Johannes Brachem
6
- License-File: LICENSE
7
- Keywords: machine-learning,statistics
8
- Classifier: Intended Audience :: Science/Research
9
- Classifier: License :: OSI Approved :: MIT License
10
- Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3.13
12
- Requires-Python: >=3.13
13
- Requires-Dist: liesel>=0.4
14
- Description-Content-Type: text/markdown
15
-
16
- # Generalized Additive Models Functionality in Liesel
17
-
18
- [![pre-commit](https://github.com/liesel-devs/liesel_gam/actions/workflows/pre-commit.yml/badge.svg)](https://github.com/liesel-devs/liesel_gam/actions/workflows/pre-commit.yml)
19
- [![pytest](https://github.com/liesel-devs/liesel_gam/actions/workflows/pytest.yml/badge.svg)](https://github.com/liesel-devs/liesel_gam/actions/workflows/pytest.yml)
20
- [![pytest-cov](tests/coverage.svg)](https://github.com/liesel-devs/liesel_gam/actions/workflows/pytest.yml)
21
-
22
- This package provides functionality to make the setup of
23
- semiparametric generalized additive distributional regression models in [Liesel](https://github.com/liesel-devs/liesel)
24
- convenient. It works nicely with [liesel-devs/smoothcon](https://github.com/liesel-devs/smoothcon),
25
- which can be used to obtain basis and penalty matrices from the R package [mgcv](https://cran.r-project.org/web/packages/mgcv/index.html).
26
-
27
- ## Disclaimer
28
-
29
- This package is experimental and under active development. That means:
30
-
31
- - The API cannot be considered stable. If you depend on this package, pin the version.
32
- - Testing has not been extensive as of now. Please check and verify!
33
- - There is currently no documentation beyond this readme.
34
-
35
- In any case, this package comes with no warranty or guarantees.
36
-
37
- ## Installation
38
-
39
- You can install the development version from GitHub via pip:
40
-
41
- ```bash
42
- pip install git+https://github.com/liesel-devs/liesel_gam.git
43
- ```
44
-
45
- ## Illustration
46
-
47
- This is a short pseudo-code illustration without real data. For full examples, please
48
- consider the [notebooks](https://github.com/liesel-devs/liesel_gam/blob/main/notebooks).
49
-
50
- ```python
51
- import liesel.model as lsl
52
- import liesel.goose as gs
53
-
54
- import liesel_gam as gam
55
-
56
- import jax.numpy as jnp
57
- ```
58
-
59
- Set up the response model.
60
-
61
- ```python
62
- loc = gam.AdditivePredictor("loc")
63
- scale = gam.AdditivePredictor("scale", inv_link=jnp.exp) # terms will be added on the linked level
64
-
65
- y = lsl.Var.new_obs(
66
- value=...,
67
- distribution=lsl.Dist(..., loc=loc, scale=scale),
68
- name="y"
69
- )
70
- ```
71
-
72
- Add intercept terms
73
-
74
- ```python
75
- loc += gam.Intercept(
76
- value=0.0, # this is the default
77
- distribution=None, # this is the default
78
- inference=gs.MCMCSpec(gs.IWLSKernel), # supply inference information here
79
- name="b0"
80
- )
81
-
82
- scale += gam.Intercept( # this term will be applied on the log link level
83
- value=0.0,
84
- distribution=None,
85
- inference=gs.MCMCSpec(gs.IWLSKernel),
86
- name="g0"
87
- )
88
-
89
- ```
90
-
91
- Add a smooth term, which can be any structured additive term defined by a basis matrix
92
- and a penalty matrix. A potentially rank-deficient multivariate normal prior will
93
- be set up for the coefficient of this term.
94
-
95
- ```python
96
- loc += gam.SmoothTerm(
97
- basis=...,
98
- penalty=...,
99
- scale=lsl.Var.new_param(..., name="tau"),
100
- inference=gs.MCMCSpec(gs.IWLSKernel),
101
- name="s(x)"
102
- )
103
- ```
104
-
105
- Add a linear term.
106
-
107
- ```python
108
- loc += gam.LinearTerm(
109
- x=..., # 1d-array or 2d-array are both allowed
110
- distribution=lsl.Dist(...),
111
- inference=gs.MCMCSpec(gs.IWLSKernel),
112
- name="x"
113
- )
114
- ```
115
-
116
- Get a Liesel EngineBuilder instance to set up MCMC sampling.
117
-
118
- ```python
119
- model = lsl.Model([y])
120
- eb = gs.LieselMCMC(model).get_engine_builder() # get your engine builder instance
121
- ```
122
-
123
- ## Contents
124
-
125
- ```python
126
- import liesel.model as lsl
127
- import liesel.goose as gs
128
-
129
- import liesel_gam as gam
130
- ```
131
-
132
- This package provides the following classes and functions:
133
-
134
- - `gam.AdditivePredictor`: A `lsl.Var` object that provides a convenient way to define an additive predictor.
135
- - `gam.SmoothTerm`: A `lsl.Var` object that provides a convenient way to set up a structured additive term with a singular multivariate normal prior, given a basis matrix, a penalty matrix, and a `lsl.Var` representing the prior scale parameter.
136
- - The alternative constructor `gam.SmoothTerm.new_ig` can be used to quickly set up a term with an inverse gamma prior on the prior variance parameter. This variance parameter will be initialized with a suitable Gibbs kernel.
137
- - `gam.LinearTerm`: A `lsl.Var` object that provides a convenient way to set up a linear term.
138
- - `gam.Intercept`: A `lsl.Var` parameter object that represents an intercept.
139
- - `gam.Basis`: An observed `lsl.Var` object that represents a basis matrix.
140
-
141
- A bit more behind the scenes:
142
-
143
- - `gam.MultivariateNormalSingular`: An implementation of the singular multivariate normal distribution in the `tensorflow_probability` interface.
144
- - `gam.star_ig_gibbs` and `gam.init_star_ig_gibbs`: Shortcuts for setting up a `gs.GibbsKernel` for a variance parameter with an inverse gamma prior.
145
-
146
- ## Usage
147
-
148
- Usage is illustrated in the following notebooks.
149
-
150
- - [notebooks/test_gam_gibbs.ipynb](https://github.com/liesel-devs/liesel_gam/blob/main/notebooks/test_gam_gibbs.ipynb): Uses the `gam.SmoothTerm.new_ig` constructor for the quickest and most convenient setup.
151
- - [notebooks/test_gam_manual.ipynb](https://github.com/liesel-devs/liesel_gam/blob/main/notebooks/test_gam_manual.ipynb): Uses `gam.SmoothTerm` with a manually initialized scale parameter. This is less convenient, but demonstrates how to use any `lsl.Var` for the scale parameter.
152
-
153
- ## Usage with bases and penalties from `mgcv` via `smoothcon`
154
-
155
- We can get access to a large class of possible basis and penalty matrices by
156
- interfacing with the wonderful R package [mgcv](https://cran.r-project.org/web/packages/mgcv/index.html)
157
- via [liesel-devs/smoothcon](https://github.com/liesel-devs/smoothcon).
158
-
159
- Example notebooks that illustrate smoothcon usage are provided in the [smoothcon
160
- repository](https://github.com/liesel-devs/smoothcon/tree/main/notebooks).
@@ -1,11 +0,0 @@
1
- liesel_gam/__about__.py,sha256=1mptEzQihbdyqqzMgdns_j5ZGK9gz7hR2bsgA_TnjO4,22
2
- liesel_gam/__init__.py,sha256=BlkbwITQP5raDtDdtg69C5yZB_pdptVcwgE3uAJWvNQ,455
3
- liesel_gam/dist.py,sha256=ZrxMjGRqNWWNGE2NAPAfvabEO6QeHteZaKFG-G6BFBI,3466
4
- liesel_gam/kernel.py,sha256=x1cPHf8orgv_X1824GYvgjIYPLydljq2Gp3xEgvAMSE,1552
5
- liesel_gam/predictor.py,sha256=SMfo7fybgAcYN9WqSyyCMmic_5GROUv6ui_aRzXdJwc,1473
6
- liesel_gam/roles.py,sha256=eZeuZI5YccNzlrgqOR5ltREB4dRBV4k4afZt9701doM,335
7
- liesel_gam/var.py,sha256=4-KEQLupQUok8ZWaiL-UF0eSRnXndeamtc3dyg6TbI0,6444
8
- liesel_gam-0.0.4.dist-info/METADATA,sha256=y7ldCSSJaS-h9P0LoDKV2DMBteYisdBIjD5NpD2Ry64,6067
9
- liesel_gam-0.0.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
10
- liesel_gam-0.0.4.dist-info/licenses/LICENSE,sha256=pjhYbDHmDl8Gms9kI5nPaJoWte2QGB0F6Cwa1r9jsQ0,1063
11
- liesel_gam-0.0.4.dist-info/RECORD,,