liesel-gam 0.0.4__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.
Potentially problematic release.
This version of liesel-gam might be problematic. Click here for more details.
- liesel_gam-0.0.4/.gitattributes +1 -0
- liesel_gam-0.0.4/.github/workflows/pre-commit.yml +36 -0
- liesel_gam-0.0.4/.github/workflows/pypi.yml +42 -0
- liesel_gam-0.0.4/.github/workflows/pytest-notebooks.yml +50 -0
- liesel_gam-0.0.4/.github/workflows/pytest.yml +70 -0
- liesel_gam-0.0.4/.gitignore +178 -0
- liesel_gam-0.0.4/.pre-commit-config.yaml +30 -0
- liesel_gam-0.0.4/LICENSE +21 -0
- liesel_gam-0.0.4/PKG-INFO +160 -0
- liesel_gam-0.0.4/README.md +145 -0
- liesel_gam-0.0.4/pyproject.toml +73 -0
- liesel_gam-0.0.4/src/liesel_gam/__about__.py +1 -0
- liesel_gam-0.0.4/src/liesel_gam/__init__.py +9 -0
- liesel_gam-0.0.4/src/liesel_gam/dist.py +100 -0
- liesel_gam-0.0.4/src/liesel_gam/kernel.py +48 -0
- liesel_gam-0.0.4/src/liesel_gam/predictor.py +48 -0
- liesel_gam-0.0.4/src/liesel_gam/roles.py +9 -0
- liesel_gam-0.0.4/src/liesel_gam/var.py +218 -0
- liesel_gam-0.0.4/uv.lock +1569 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
*.ipynb linguist-vendored
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: pre-commit
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
pre-commit:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
timeout-minutes: 10
|
|
13
|
+
|
|
14
|
+
steps:
|
|
15
|
+
- name: Check out repository
|
|
16
|
+
uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- name: Install uv
|
|
19
|
+
uses: astral-sh/setup-uv@v5
|
|
20
|
+
|
|
21
|
+
- name: "Set up Python"
|
|
22
|
+
uses: actions/setup-python@v5
|
|
23
|
+
with:
|
|
24
|
+
python-version-file: "pyproject.toml"
|
|
25
|
+
|
|
26
|
+
- name: Set up R
|
|
27
|
+
uses: r-lib/actions/setup-r@v2
|
|
28
|
+
with:
|
|
29
|
+
r-version: 'release'
|
|
30
|
+
use-public-rspm: true
|
|
31
|
+
|
|
32
|
+
- name: Install Package
|
|
33
|
+
run: uv sync --locked --group dev
|
|
34
|
+
|
|
35
|
+
- name: Run pre-commit
|
|
36
|
+
run: uv run pre-commit run -a
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# This workflow will upload a Python Package using Twine when a release is created
|
|
2
|
+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
|
|
3
|
+
|
|
4
|
+
# This workflow uses actions that are not certified by GitHub.
|
|
5
|
+
# They are provided by a third-party and are governed by
|
|
6
|
+
# separate terms of service, privacy policy, and support
|
|
7
|
+
# documentation.
|
|
8
|
+
|
|
9
|
+
name: Upload Python Package
|
|
10
|
+
|
|
11
|
+
on:
|
|
12
|
+
workflow_dispatch: # trigger manually from GitHub UI
|
|
13
|
+
release:
|
|
14
|
+
types: [published]
|
|
15
|
+
|
|
16
|
+
permissions:
|
|
17
|
+
contents: read
|
|
18
|
+
|
|
19
|
+
jobs:
|
|
20
|
+
deploy:
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
|
|
23
|
+
steps:
|
|
24
|
+
- name: Check out repository
|
|
25
|
+
uses: actions/checkout@v4
|
|
26
|
+
|
|
27
|
+
- name: Install uv
|
|
28
|
+
uses: astral-sh/setup-uv@v5
|
|
29
|
+
|
|
30
|
+
- name: "Set up Python"
|
|
31
|
+
uses: actions/setup-python@v5
|
|
32
|
+
with:
|
|
33
|
+
python-version-file: "pyproject.toml"
|
|
34
|
+
|
|
35
|
+
- name: Build package
|
|
36
|
+
run: uv build
|
|
37
|
+
|
|
38
|
+
- name: Publish package
|
|
39
|
+
uses: pypa/gh-action-pypi-publish@v1.5.0
|
|
40
|
+
with:
|
|
41
|
+
user: __token__
|
|
42
|
+
password: ${{ secrets.PYPI_UPLOAD }}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
name: notebooks
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
pytest:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
timeout-minutes: 10
|
|
11
|
+
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.13"]
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- name: Check out repository
|
|
18
|
+
uses: actions/checkout@v4
|
|
19
|
+
|
|
20
|
+
- name: Install uv and set the python version
|
|
21
|
+
uses: astral-sh/setup-uv@v5
|
|
22
|
+
with:
|
|
23
|
+
python-version: ${{ matrix.python-version }}
|
|
24
|
+
enable-cache: true
|
|
25
|
+
cache-dependency-glob: "uv.lock"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
- name: Set up R
|
|
29
|
+
uses: r-lib/actions/setup-r@v2
|
|
30
|
+
with:
|
|
31
|
+
r-version: 'release'
|
|
32
|
+
use-public-rspm: true
|
|
33
|
+
|
|
34
|
+
- name: Install Package
|
|
35
|
+
run: uv sync --locked --group dev
|
|
36
|
+
|
|
37
|
+
- name: Add R shared libraries to LD_LIBRARY_PATH
|
|
38
|
+
run: |
|
|
39
|
+
echo "LD_LIBRARY_PATH=$(python -m rpy2.situation LD_LIBRARY_PATH):\$LD_LIBRARY_PATH" >> $GITHUB_ENV
|
|
40
|
+
|
|
41
|
+
- name: Debug R environment
|
|
42
|
+
run: |
|
|
43
|
+
echo "R_HOME=$(R RHOME)"
|
|
44
|
+
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
|
|
45
|
+
find $(R RHOME) -name methods.so
|
|
46
|
+
find $(R RHOME) -name libR.so
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
- name: Run pytest
|
|
50
|
+
run: uv run pytest tests/notebooks --nbval-lax --nbval-current-env
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
name: pytest
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
pytest:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
timeout-minutes: 10
|
|
11
|
+
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.13"]
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- name: Check out repository
|
|
18
|
+
uses: actions/checkout@v4
|
|
19
|
+
|
|
20
|
+
- name: Install uv and set the python version
|
|
21
|
+
uses: astral-sh/setup-uv@v5
|
|
22
|
+
with:
|
|
23
|
+
python-version: ${{ matrix.python-version }}
|
|
24
|
+
enable-cache: true
|
|
25
|
+
cache-dependency-glob: "uv.lock"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
- name: Set up R
|
|
29
|
+
uses: r-lib/actions/setup-r@v2
|
|
30
|
+
with:
|
|
31
|
+
r-version: 'release'
|
|
32
|
+
use-public-rspm: true
|
|
33
|
+
|
|
34
|
+
- name: Install Package
|
|
35
|
+
run: uv sync --locked --group dev
|
|
36
|
+
|
|
37
|
+
- name: Add R shared libraries to LD_LIBRARY_PATH
|
|
38
|
+
run: |
|
|
39
|
+
echo "LD_LIBRARY_PATH=$(python -m rpy2.situation LD_LIBRARY_PATH):\$LD_LIBRARY_PATH" >> $GITHUB_ENV
|
|
40
|
+
|
|
41
|
+
- name: Debug R environment
|
|
42
|
+
run: |
|
|
43
|
+
echo "R_HOME=$(R RHOME)"
|
|
44
|
+
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
|
|
45
|
+
find $(R RHOME) -name methods.so
|
|
46
|
+
find $(R RHOME) -name libR.so
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
- name: Run pytest
|
|
50
|
+
run: uv run pytest --cov=liesel_gam
|
|
51
|
+
|
|
52
|
+
- name: Create coverage badge
|
|
53
|
+
uses: tj-actions/coverage-badge-py@v2
|
|
54
|
+
with:
|
|
55
|
+
output: tests/coverage.svg
|
|
56
|
+
overwrite: true
|
|
57
|
+
|
|
58
|
+
- name: Commit coverage.svg
|
|
59
|
+
run: |
|
|
60
|
+
git config --local user.name "github-actions[bot]"
|
|
61
|
+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
|
|
62
|
+
git ls-remote | grep refs/heads/pytest-cov && git remote set-branches --add origin pytest-cov && git fetch
|
|
63
|
+
git add tests/coverage.svg
|
|
64
|
+
git diff --staged --quiet || git commit -m "Updated coverage.svg"
|
|
65
|
+
|
|
66
|
+
- name: Push coverage.svg
|
|
67
|
+
uses: ad-m/github-push-action@master
|
|
68
|
+
with:
|
|
69
|
+
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
70
|
+
branch: ${{ github.ref }}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
|
|
110
|
+
# pdm
|
|
111
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
112
|
+
#pdm.lock
|
|
113
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
114
|
+
# in version control.
|
|
115
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
|
116
|
+
.pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
121
|
+
__pypackages__/
|
|
122
|
+
|
|
123
|
+
# Celery stuff
|
|
124
|
+
celerybeat-schedule
|
|
125
|
+
celerybeat.pid
|
|
126
|
+
|
|
127
|
+
# SageMath parsed files
|
|
128
|
+
*.sage.py
|
|
129
|
+
|
|
130
|
+
# Environments
|
|
131
|
+
.env
|
|
132
|
+
.venv
|
|
133
|
+
env/
|
|
134
|
+
venv/
|
|
135
|
+
ENV/
|
|
136
|
+
env.bak/
|
|
137
|
+
venv.bak/
|
|
138
|
+
|
|
139
|
+
# Spyder project settings
|
|
140
|
+
.spyderproject
|
|
141
|
+
.spyproject
|
|
142
|
+
|
|
143
|
+
# Rope project settings
|
|
144
|
+
.ropeproject
|
|
145
|
+
|
|
146
|
+
# mkdocs documentation
|
|
147
|
+
/site
|
|
148
|
+
|
|
149
|
+
# mypy
|
|
150
|
+
.mypy_cache/
|
|
151
|
+
.dmypy.json
|
|
152
|
+
dmypy.json
|
|
153
|
+
|
|
154
|
+
# Pyre type checker
|
|
155
|
+
.pyre/
|
|
156
|
+
|
|
157
|
+
# pytype static type analyzer
|
|
158
|
+
.pytype/
|
|
159
|
+
|
|
160
|
+
# Cython debug symbols
|
|
161
|
+
cython_debug/
|
|
162
|
+
|
|
163
|
+
# PyCharm
|
|
164
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
165
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
166
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
167
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
168
|
+
#.idea/
|
|
169
|
+
|
|
170
|
+
# Ruff stuff:
|
|
171
|
+
.ruff_cache/
|
|
172
|
+
|
|
173
|
+
# PyPI configuration file
|
|
174
|
+
.pypirc
|
|
175
|
+
.python-version
|
|
176
|
+
/.vscode
|
|
177
|
+
/tests/data
|
|
178
|
+
.DS_Store
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# see https://pre-commit.com for more information
|
|
2
|
+
# see https://pre-commit.com/hooks.html for more hooks
|
|
3
|
+
|
|
4
|
+
repos:
|
|
5
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
6
|
+
rev: v5.0.0
|
|
7
|
+
hooks:
|
|
8
|
+
- id: check-added-large-files
|
|
9
|
+
args: ["--maxkb=1000"]
|
|
10
|
+
- id: check-yaml
|
|
11
|
+
- id: end-of-file-fixer
|
|
12
|
+
- id: trailing-whitespace
|
|
13
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
14
|
+
rev: v0.11.8
|
|
15
|
+
hooks:
|
|
16
|
+
# Run the formatter.
|
|
17
|
+
- id: ruff-format
|
|
18
|
+
# Run the linter.
|
|
19
|
+
- id: ruff
|
|
20
|
+
args: [ --fix ]
|
|
21
|
+
- repo: local
|
|
22
|
+
hooks:
|
|
23
|
+
- id: mypy
|
|
24
|
+
name: mypy
|
|
25
|
+
entry: mypy
|
|
26
|
+
language: python
|
|
27
|
+
types_or: [python, pyi]
|
|
28
|
+
args: [--ignore-missing-imports, --scripts-are-modules]
|
|
29
|
+
require_serial: true
|
|
30
|
+
exclude: ^docs/
|
liesel_gam-0.0.4/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Liesel
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,160 @@
|
|
|
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
|
+
[](https://github.com/liesel-devs/liesel_gam/actions/workflows/pre-commit.yml)
|
|
19
|
+
[](https://github.com/liesel-devs/liesel_gam/actions/workflows/pytest.yml)
|
|
20
|
+
[](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).
|