pylgm 0.3.0__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.
- pylgm-0.3.0/.github/workflows/docs.yml +42 -0
- pylgm-0.3.0/.github/workflows/publish.yml +23 -0
- pylgm-0.3.0/.github/workflows/test.yml +53 -0
- pylgm-0.3.0/.gitignore +7 -0
- pylgm-0.3.0/LICENSE +21 -0
- pylgm-0.3.0/PKG-INFO +114 -0
- pylgm-0.3.0/README.md +78 -0
- pylgm-0.3.0/docs/design/plans/2026-07-22-pylgm-gaussian-foundation.md +1204 -0
- pylgm-0.3.0/docs/design/plans/2026-07-22-pylgm-predictive-selection.md +914 -0
- pylgm-0.3.0/docs/design/plans/2026-08-08-pylgm-general-lgm-foundation.md +540 -0
- pylgm-0.3.0/docs/design/plans/2026-08-17-pylgm-pyspark-adapter.md +362 -0
- pylgm-0.3.0/docs/design/plans/2026-08-19-pylgm-declarative-empirical-bayes.md +793 -0
- pylgm-0.3.0/docs/design/plans/2026-08-19-pylgm-non-gaussian-laplace.md +1151 -0
- pylgm-0.3.0/docs/design/plans/2026-08-20-pylgm-inla-criteria.md +496 -0
- pylgm-0.3.0/docs/design/plans/2026-08-20-pylgm-inla-integration.md +672 -0
- pylgm-0.3.0/docs/design/plans/2026-08-20-pylgm-penalized-map-ii.md +313 -0
- pylgm-0.3.0/docs/design/plans/2026-08-21-pylgm-inla-full-laplace.md +324 -0
- pylgm-0.3.0/docs/design/plans/2026-08-21-pylgm-inla-simplified-laplace.md +414 -0
- pylgm-0.3.0/docs/design/plans/2026-08-23-pylgm-besag-icar.md +801 -0
- pylgm-0.3.0/docs/design/plans/2026-08-23-pylgm-bounded-hyperparameter-inference.md +941 -0
- pylgm-0.3.0/docs/design/plans/2026-08-23-pylgm-bym2.md +900 -0
- pylgm-0.3.0/docs/design/plans/2026-08-23-pylgm-proper-car.md +590 -0
- pylgm-0.3.0/docs/design/plans/2026-08-24-pylgm-ar1.md +536 -0
- pylgm-0.3.0/docs/design/plans/2026-08-24-pylgm-followups.md +255 -0
- pylgm-0.3.0/docs/design/plans/2026-08-24-pylgm-out-of-sample-prediction.md +518 -0
- pylgm-0.3.0/docs/design/plans/2026-08-24-pylgm-result-unification.md +372 -0
- pylgm-0.3.0/docs/design/specs/2026-07-22-pylgm-design.md +515 -0
- pylgm-0.3.0/docs/design/specs/2026-07-22-pylgm-predictive-selection-design.md +224 -0
- pylgm-0.3.0/docs/design/specs/2026-08-08-pylgm-latte-pyspark-architecture.md +619 -0
- pylgm-0.3.0/docs/design/specs/2026-08-17-pylgm-pyspark-adapter-design.md +186 -0
- pylgm-0.3.0/docs/design/specs/2026-08-19-pylgm-declarative-empirical-bayes-design.md +228 -0
- pylgm-0.3.0/docs/design/specs/2026-08-19-pylgm-non-gaussian-laplace-design.md +272 -0
- pylgm-0.3.0/docs/design/specs/2026-08-20-pylgm-inla-criteria-design.md +194 -0
- pylgm-0.3.0/docs/design/specs/2026-08-20-pylgm-inla-integration-design.md +215 -0
- pylgm-0.3.0/docs/design/specs/2026-08-20-pylgm-penalized-map-ii-design.md +163 -0
- pylgm-0.3.0/docs/design/specs/2026-08-21-pylgm-inla-full-laplace-design.md +163 -0
- pylgm-0.3.0/docs/design/specs/2026-08-21-pylgm-inla-simplified-laplace-design.md +186 -0
- pylgm-0.3.0/docs/design/specs/2026-08-23-pylgm-besag-icar-design.md +237 -0
- pylgm-0.3.0/docs/design/specs/2026-08-23-pylgm-bounded-hyperparameter-inference-design.md +268 -0
- pylgm-0.3.0/docs/design/specs/2026-08-23-pylgm-bym2-design.md +240 -0
- pylgm-0.3.0/docs/design/specs/2026-08-23-pylgm-proper-car-design.md +182 -0
- pylgm-0.3.0/docs/design/specs/2026-08-24-pylgm-ar1-design.md +179 -0
- pylgm-0.3.0/docs/design/specs/2026-08-24-pylgm-newton-stall-rescue-design.md +149 -0
- pylgm-0.3.0/docs/design/specs/2026-08-24-pylgm-out-of-sample-prediction-design.md +217 -0
- pylgm-0.3.0/docs/design/specs/2026-08-24-pylgm-result-unification-design.md +184 -0
- pylgm-0.3.0/docs/development.md +8 -0
- pylgm-0.3.0/docs/effects.md +96 -0
- pylgm-0.3.0/docs/empirical-bayes.md +91 -0
- pylgm-0.3.0/docs/examples-count-regression.md +89 -0
- pylgm-0.3.0/docs/examples-disease-mapping.md +81 -0
- pylgm-0.3.0/docs/img/crabs_fit.png +0 -0
- pylgm-0.3.0/docs/img/crabs_prediction.png +0 -0
- pylgm-0.3.0/docs/img/scotland_fit.png +0 -0
- pylgm-0.3.0/docs/img/scotland_shrinkage.png +0 -0
- pylgm-0.3.0/docs/index.md +64 -0
- pylgm-0.3.0/docs/inla.md +209 -0
- pylgm-0.3.0/docs/internals.md +100 -0
- pylgm-0.3.0/docs/likelihoods.md +158 -0
- pylgm-0.3.0/docs/prediction.md +142 -0
- pylgm-0.3.0/docs/roadmap.md +51 -0
- pylgm-0.3.0/docs/spark.md +57 -0
- pylgm-0.3.0/docs/spatial-effects.md +296 -0
- pylgm-0.3.0/docs/theory.md +205 -0
- pylgm-0.3.0/examples/count_glm/README.md +31 -0
- pylgm-0.3.0/examples/count_glm/config.yaml +11 -0
- pylgm-0.3.0/examples/count_glm/data.csv +9 -0
- pylgm-0.3.0/examples/count_glm/run.py +22 -0
- pylgm-0.3.0/examples/count_regression/README.md +19 -0
- pylgm-0.3.0/examples/count_regression/data.csv +174 -0
- pylgm-0.3.0/examples/count_regression/run.py +155 -0
- pylgm-0.3.0/examples/disease_mapping/README.md +19 -0
- pylgm-0.3.0/examples/disease_mapping/data.csv +57 -0
- pylgm-0.3.0/examples/disease_mapping/graph.json +1 -0
- pylgm-0.3.0/examples/disease_mapping/run.py +134 -0
- pylgm-0.3.0/examples/empirical_bayes/README.md +42 -0
- pylgm-0.3.0/examples/empirical_bayes/data.csv +81 -0
- pylgm-0.3.0/examples/empirical_bayes/run.py +33 -0
- pylgm-0.3.0/examples/general_lgm/README.md +41 -0
- pylgm-0.3.0/examples/general_lgm/config.yaml +18 -0
- pylgm-0.3.0/examples/general_lgm/data.csv +7 -0
- pylgm-0.3.0/examples/general_lgm/run.py +40 -0
- pylgm-0.3.0/examples/general_lgm/run_spark.py +32 -0
- pylgm-0.3.0/examples/inla/README.md +59 -0
- pylgm-0.3.0/examples/inla/data.csv +145 -0
- pylgm-0.3.0/examples/inla/run.py +43 -0
- pylgm-0.3.0/examples/inla_criteria/README.md +64 -0
- pylgm-0.3.0/examples/inla_criteria/data.csv +145 -0
- pylgm-0.3.0/examples/inla_criteria/run.py +40 -0
- pylgm-0.3.0/examples/inla_full_laplace/README.md +78 -0
- pylgm-0.3.0/examples/inla_full_laplace/data.csv +133 -0
- pylgm-0.3.0/examples/inla_full_laplace/run.py +69 -0
- pylgm-0.3.0/examples/inla_sla/README.md +68 -0
- pylgm-0.3.0/examples/inla_sla/data.csv +133 -0
- pylgm-0.3.0/examples/inla_sla/run.py +52 -0
- pylgm-0.3.0/examples/map_ii/README.md +53 -0
- pylgm-0.3.0/examples/map_ii/data.csv +81 -0
- pylgm-0.3.0/examples/map_ii/run.py +37 -0
- pylgm-0.3.0/examples/nic_backtest/README.md +25 -0
- pylgm-0.3.0/examples/nic_backtest/config.yaml +38 -0
- pylgm-0.3.0/examples/predictive_selection/README.md +20 -0
- pylgm-0.3.0/examples/predictive_selection/config.yaml +36 -0
- pylgm-0.3.0/examples/predictive_selection/data.csv +31 -0
- pylgm-0.3.0/examples/synthetic_panel/README.md +23 -0
- pylgm-0.3.0/examples/synthetic_panel/config.yaml +13 -0
- pylgm-0.3.0/examples/synthetic_panel/data.csv +9 -0
- pylgm-0.3.0/mkdocs.yml +52 -0
- pylgm-0.3.0/pyproject.toml +68 -0
- pylgm-0.3.0/src/pylgm/__init__.py +37 -0
- pylgm-0.3.0/src/pylgm/artifacts/__init__.py +6 -0
- pylgm-0.3.0/src/pylgm/artifacts/experiment.py +206 -0
- pylgm-0.3.0/src/pylgm/artifacts/run.py +252 -0
- pylgm-0.3.0/src/pylgm/cli.py +49 -0
- pylgm-0.3.0/src/pylgm/compiler.py +667 -0
- pylgm-0.3.0/src/pylgm/config/__init__.py +15 -0
- pylgm-0.3.0/src/pylgm/config/experiment.py +271 -0
- pylgm-0.3.0/src/pylgm/config/load.py +57 -0
- pylgm-0.3.0/src/pylgm/config/model.py +151 -0
- pylgm-0.3.0/src/pylgm/config/schema.py +79 -0
- pylgm-0.3.0/src/pylgm/data/__init__.py +3 -0
- pylgm-0.3.0/src/pylgm/data/fingerprint.py +215 -0
- pylgm-0.3.0/src/pylgm/data/panel.py +126 -0
- pylgm-0.3.0/src/pylgm/data/scalars.py +69 -0
- pylgm-0.3.0/src/pylgm/data/spark.py +114 -0
- pylgm-0.3.0/src/pylgm/effects/__init__.py +31 -0
- pylgm-0.3.0/src/pylgm/effects/ar1.py +58 -0
- pylgm-0.3.0/src/pylgm/effects/besag.py +71 -0
- pylgm-0.3.0/src/pylgm/effects/bym2.py +58 -0
- pylgm-0.3.0/src/pylgm/effects/fixed.py +19 -0
- pylgm-0.3.0/src/pylgm/effects/graph.py +144 -0
- pylgm-0.3.0/src/pylgm/effects/iid.py +22 -0
- pylgm-0.3.0/src/pylgm/effects/proper_car.py +88 -0
- pylgm-0.3.0/src/pylgm/effects/random_walk.py +55 -0
- pylgm-0.3.0/src/pylgm/effects/spec.py +236 -0
- pylgm-0.3.0/src/pylgm/evaluation/__init__.py +21 -0
- pylgm-0.3.0/src/pylgm/evaluation/availability.py +30 -0
- pylgm-0.3.0/src/pylgm/evaluation/folds.py +297 -0
- pylgm-0.3.0/src/pylgm/evaluation/metrics.py +304 -0
- pylgm-0.3.0/src/pylgm/evaluation/persistence.py +89 -0
- pylgm-0.3.0/src/pylgm/evaluation/selection.py +174 -0
- pylgm-0.3.0/src/pylgm/exceptions.py +105 -0
- pylgm-0.3.0/src/pylgm/experiment.py +479 -0
- pylgm-0.3.0/src/pylgm/inference/__init__.py +26 -0
- pylgm-0.3.0/src/pylgm/inference/gaussian.py +174 -0
- pylgm-0.3.0/src/pylgm/inference/laplace.py +171 -0
- pylgm-0.3.0/src/pylgm/inference/prediction.py +232 -0
- pylgm-0.3.0/src/pylgm/inference/result.py +990 -0
- pylgm-0.3.0/src/pylgm/ir/__init__.py +25 -0
- pylgm-0.3.0/src/pylgm/ir/family.py +462 -0
- pylgm-0.3.0/src/pylgm/ir/model.py +275 -0
- pylgm-0.3.0/src/pylgm/likelihoods.py +198 -0
- pylgm-0.3.0/src/pylgm/links.py +38 -0
- pylgm-0.3.0/src/pylgm/model.py +350 -0
- pylgm-0.3.0/src/pylgm/optimization/__init__.py +16 -0
- pylgm-0.3.0/src/pylgm/optimization/empirical_bayes.py +322 -0
- pylgm-0.3.0/src/pylgm/optimization/inla.py +504 -0
- pylgm-0.3.0/src/pylgm/optimization/result.py +92 -0
- pylgm-0.3.0/src/pylgm/optimization/transforms.py +83 -0
- pylgm-0.3.0/src/pylgm/parameters.py +95 -0
- pylgm-0.3.0/src/pylgm/pipeline.py +28 -0
- pylgm-0.3.0/src/pylgm/priors.py +223 -0
- pylgm-0.3.0/tests/artifacts/test_experiment_artifacts.py +317 -0
- pylgm-0.3.0/tests/config/__init__.py +1 -0
- pylgm-0.3.0/tests/config/test_experiment.py +395 -0
- pylgm-0.3.0/tests/config/test_load.py +137 -0
- pylgm-0.3.0/tests/config/test_model.py +223 -0
- pylgm-0.3.0/tests/conftest.py +17 -0
- pylgm-0.3.0/tests/data/test_panel.py +101 -0
- pylgm-0.3.0/tests/data/test_spark.py +260 -0
- pylgm-0.3.0/tests/effects/test_ar1.py +69 -0
- pylgm-0.3.0/tests/effects/test_besag.py +107 -0
- pylgm-0.3.0/tests/effects/test_bym2.py +74 -0
- pylgm-0.3.0/tests/effects/test_graph.py +94 -0
- pylgm-0.3.0/tests/effects/test_proper_car.py +85 -0
- pylgm-0.3.0/tests/effects/test_spec.py +239 -0
- pylgm-0.3.0/tests/effects/test_structured.py +71 -0
- pylgm-0.3.0/tests/evaluation/test_folds.py +442 -0
- pylgm-0.3.0/tests/evaluation/test_metrics.py +318 -0
- pylgm-0.3.0/tests/evaluation/test_persistence.py +143 -0
- pylgm-0.3.0/tests/evaluation/test_selection.py +189 -0
- pylgm-0.3.0/tests/inference/result_surface_baseline.json +4318 -0
- pylgm-0.3.0/tests/inference/test_gaussian.py +470 -0
- pylgm-0.3.0/tests/inference/test_laplace.py +152 -0
- pylgm-0.3.0/tests/inference/test_prediction.py +106 -0
- pylgm-0.3.0/tests/inference/test_predictive_variance_convention.py +93 -0
- pylgm-0.3.0/tests/inference/test_result.py +554 -0
- pylgm-0.3.0/tests/inference/test_result_surface.py +798 -0
- pylgm-0.3.0/tests/inference/test_tabulated_marginals.py +33 -0
- pylgm-0.3.0/tests/integration/test_nic_shaped_backtest.py +81 -0
- pylgm-0.3.0/tests/integration/test_predictive_selection.py +23 -0
- pylgm-0.3.0/tests/integration/test_synthetic_example.py +15 -0
- pylgm-0.3.0/tests/ir/test_compiled_family.py +54 -0
- pylgm-0.3.0/tests/ir/test_fixed.py +94 -0
- pylgm-0.3.0/tests/ir/test_gaussian_family.py +432 -0
- pylgm-0.3.0/tests/ir/test_model_validation.py +288 -0
- pylgm-0.3.0/tests/ir/test_parametric_block.py +140 -0
- pylgm-0.3.0/tests/optimization/test_empirical_bayes.py +965 -0
- pylgm-0.3.0/tests/optimization/test_full_laplace.py +131 -0
- pylgm-0.3.0/tests/optimization/test_inla.py +193 -0
- pylgm-0.3.0/tests/optimization/test_inla_criteria.py +100 -0
- pylgm-0.3.0/tests/optimization/test_simplified_laplace.py +86 -0
- pylgm-0.3.0/tests/optimization/test_skew_normal.py +33 -0
- pylgm-0.3.0/tests/optimization/test_transforms.py +67 -0
- pylgm-0.3.0/tests/test_ar1_fit.py +120 -0
- pylgm-0.3.0/tests/test_besag_fit.py +155 -0
- pylgm-0.3.0/tests/test_bym2_fit.py +95 -0
- pylgm-0.3.0/tests/test_cli.py +110 -0
- pylgm-0.3.0/tests/test_compiler.py +691 -0
- pylgm-0.3.0/tests/test_experiment.py +366 -0
- pylgm-0.3.0/tests/test_links.py +22 -0
- pylgm-0.3.0/tests/test_model.py +750 -0
- pylgm-0.3.0/tests/test_model_spark.py +78 -0
- pylgm-0.3.0/tests/test_modeling_vocabulary.py +214 -0
- pylgm-0.3.0/tests/test_package.py +142 -0
- pylgm-0.3.0/tests/test_parameters.py +28 -0
- pylgm-0.3.0/tests/test_pc_bym2_phi.py +87 -0
- pylgm-0.3.0/tests/test_pipeline.py +382 -0
- pylgm-0.3.0/tests/test_predict.py +217 -0
- pylgm-0.3.0/tests/test_proper_car_fit.py +96 -0
- pylgm-0.3.0/tests/test_proper_car_rho_estimation.py +103 -0
- pylgm-0.3.0/tests/test_public_exports.py +28 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
name: docs
|
|
2
|
+
|
|
3
|
+
# Builds the MkDocs site and deploys it to GitHub Pages on every push to main.
|
|
4
|
+
# One-time setup: enable Pages for the repo with "GitHub Actions" as the source
|
|
5
|
+
# (Settings -> Pages). Site URL: https://ardea00.github.io/pylgm/
|
|
6
|
+
on:
|
|
7
|
+
push:
|
|
8
|
+
branches: [main]
|
|
9
|
+
|
|
10
|
+
permissions:
|
|
11
|
+
contents: read
|
|
12
|
+
pages: write
|
|
13
|
+
id-token: write
|
|
14
|
+
|
|
15
|
+
# Allow one concurrent deployment; don't cancel an in-progress one.
|
|
16
|
+
concurrency:
|
|
17
|
+
group: pages
|
|
18
|
+
cancel-in-progress: false
|
|
19
|
+
|
|
20
|
+
jobs:
|
|
21
|
+
build:
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v4
|
|
25
|
+
- uses: actions/setup-python@v5
|
|
26
|
+
with:
|
|
27
|
+
python-version: "3.11"
|
|
28
|
+
- run: python -m pip install .[docs]
|
|
29
|
+
- run: mkdocs build --strict
|
|
30
|
+
- uses: actions/upload-pages-artifact@v3
|
|
31
|
+
with:
|
|
32
|
+
path: site
|
|
33
|
+
|
|
34
|
+
deploy:
|
|
35
|
+
needs: build
|
|
36
|
+
runs-on: ubuntu-latest
|
|
37
|
+
environment:
|
|
38
|
+
name: github-pages
|
|
39
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
40
|
+
steps:
|
|
41
|
+
- id: deployment
|
|
42
|
+
uses: actions/deploy-pages@v4
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
name: publish
|
|
2
|
+
|
|
3
|
+
# Publishes to PyPI when a GitHub Release is published. Uses Trusted
|
|
4
|
+
# Publishing (OIDC) -- no API token is stored; PyPI must have a trusted
|
|
5
|
+
# publisher configured for this repo/workflow (one-time setup on pypi.org).
|
|
6
|
+
on:
|
|
7
|
+
release:
|
|
8
|
+
types: [published]
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
pypi:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
environment: pypi
|
|
14
|
+
permissions:
|
|
15
|
+
id-token: write # required for Trusted Publishing
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
- uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: "3.11"
|
|
21
|
+
- run: python -m pip install --upgrade build
|
|
22
|
+
- run: python -m build
|
|
23
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
name: test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
core:
|
|
10
|
+
runs-on: ${{ matrix.os }}
|
|
11
|
+
strategy:
|
|
12
|
+
fail-fast: false
|
|
13
|
+
matrix:
|
|
14
|
+
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
15
|
+
python-version: ["3.11", "3.12", "3.13"]
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
- uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: ${{ matrix.python-version }}
|
|
21
|
+
- run: python -m pip install --upgrade pip
|
|
22
|
+
- run: python -m pip install -e ".[dev]"
|
|
23
|
+
- run: ruff check src tests
|
|
24
|
+
- run: pytest -q
|
|
25
|
+
|
|
26
|
+
release-gate:
|
|
27
|
+
# Non-editable install exercises the real hatchling build and the console
|
|
28
|
+
# entry point exactly as `pip install pylgm` would for a released user.
|
|
29
|
+
runs-on: ubuntu-latest
|
|
30
|
+
steps:
|
|
31
|
+
- uses: actions/checkout@v4
|
|
32
|
+
- uses: actions/setup-python@v5
|
|
33
|
+
with:
|
|
34
|
+
python-version: "3.11"
|
|
35
|
+
- run: python -m pip install --upgrade pip
|
|
36
|
+
- run: python -m pip install .
|
|
37
|
+
- run: pylgm --help
|
|
38
|
+
|
|
39
|
+
spark:
|
|
40
|
+
runs-on: ubuntu-latest
|
|
41
|
+
steps:
|
|
42
|
+
- uses: actions/checkout@v4
|
|
43
|
+
- uses: actions/setup-python@v5
|
|
44
|
+
with:
|
|
45
|
+
python-version: "3.11"
|
|
46
|
+
- uses: actions/setup-java@v4
|
|
47
|
+
with:
|
|
48
|
+
distribution: temurin
|
|
49
|
+
java-version: "17"
|
|
50
|
+
- run: python -m pip install --upgrade pip
|
|
51
|
+
- run: python -m pip install -e ".[dev,spark]"
|
|
52
|
+
# Spark and Java are provisioned here, so these tests must run unskipped.
|
|
53
|
+
- run: pytest tests/data/test_spark.py tests/test_model_spark.py -q
|
pylgm-0.3.0/.gitignore
ADDED
pylgm-0.3.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Andrea Panozzo
|
|
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.
|
pylgm-0.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: pylgm
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: General-purpose latent Gaussian models for Python
|
|
5
|
+
Project-URL: Homepage, https://github.com/Ardea00/pylgm
|
|
6
|
+
Project-URL: Repository, https://github.com/Ardea00/pylgm
|
|
7
|
+
Project-URL: Issues, https://github.com/Ardea00/pylgm/issues
|
|
8
|
+
Author: Andrea Panozzo
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: bayesian,inla,laplace approximation,latent gaussian models,statistics
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Requires-Dist: formulaic>=1.1
|
|
21
|
+
Requires-Dist: numpy>=2.0
|
|
22
|
+
Requires-Dist: pandas>=2.2
|
|
23
|
+
Requires-Dist: pyarrow>=17
|
|
24
|
+
Requires-Dist: pydantic>=2.8
|
|
25
|
+
Requires-Dist: pyyaml>=6.0
|
|
26
|
+
Requires-Dist: scipy>=1.14
|
|
27
|
+
Requires-Dist: typer>=0.15
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=8.3; extra == 'dev'
|
|
30
|
+
Requires-Dist: ruff>=0.9; extra == 'dev'
|
|
31
|
+
Provides-Extra: docs
|
|
32
|
+
Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
|
|
33
|
+
Provides-Extra: spark
|
|
34
|
+
Requires-Dist: pyspark>=3.5; extra == 'spark'
|
|
35
|
+
Description-Content-Type: text/markdown
|
|
36
|
+
|
|
37
|
+
# pyLGM
|
|
38
|
+
|
|
39
|
+
General-purpose **latent Gaussian models** for Python — the model class behind
|
|
40
|
+
INLA. Fit fixed effects, random effects, temporal (RW/AR1) and spatial (CAR)
|
|
41
|
+
structure under Gaussian, Poisson, or Bernoulli likelihoods, from a Pandas (or
|
|
42
|
+
Spark) DataFrame, with exact-Gaussian and Laplace inference engines, empirical
|
|
43
|
+
Bayes / MAP-II hyperparameter estimation, and INLA-style posterior integration.
|
|
44
|
+
|
|
45
|
+
## Install
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install pylgm
|
|
49
|
+
pip install "pylgm[spark]" # optional: Spark data boundary
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Requires Python ≥ 3.11.
|
|
53
|
+
|
|
54
|
+
## 30-second example
|
|
55
|
+
|
|
56
|
+
A Poisson model with a per-region random intercept, fit with the Laplace engine:
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
import pandas as pd
|
|
60
|
+
from pylgm import Fixed, IID, LGM, Poisson
|
|
61
|
+
|
|
62
|
+
# Counts of events per region over time, with a covariate x.
|
|
63
|
+
frame = pd.DataFrame({
|
|
64
|
+
"region": ["north", "north", "north", "south", "south", "south"],
|
|
65
|
+
"time": [1, 2, 3, 1, 2, 3],
|
|
66
|
+
"x": [0.0, 0.5, 1.0, 0.0, 0.5, 1.0],
|
|
67
|
+
"count": [3, 5, 8, 2, 3, 5],
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
model = LGM(
|
|
71
|
+
response="count",
|
|
72
|
+
likelihood=Poisson(), # canonical log link
|
|
73
|
+
predictor=Fixed("1 + x") # fixed effects
|
|
74
|
+
+ IID("region", index="region", precision=2.0), # random intercept per region
|
|
75
|
+
panel=("region",),
|
|
76
|
+
time="time",
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
result = model.fit(frame, engine="laplace")
|
|
80
|
+
print("fitted_mean:", result.fitted_mean.round(3).tolist())
|
|
81
|
+
# fitted_mean: [3.254, 4.986, 8.15, 2.201, 3.373, 5.513]
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
The same model can be declared in YAML and loaded with `pylgm.config.load_model`.
|
|
85
|
+
See the [general LGM example](examples/general_lgm/README.md), which fits the
|
|
86
|
+
same data through both the Python and YAML frontends, and the other 13 runnable
|
|
87
|
+
scripts under [`examples/`](examples/).
|
|
88
|
+
|
|
89
|
+
## What's in the box
|
|
90
|
+
|
|
91
|
+
| Area | What you get | Docs |
|
|
92
|
+
|---|---|---|
|
|
93
|
+
| **Likelihoods** | Gaussian (exact), Poisson & Bernoulli (Laplace) | [likelihoods](docs/likelihoods.md) |
|
|
94
|
+
| **Effects** | `Fixed`, `IID`, `RW1`/`RW2`, stationary `AR1` | [effects](docs/effects.md) |
|
|
95
|
+
| **Spatial** | `Besag` (ICAR), `ProperCAR` (with ρ), `BYM2` (with φ) | [spatial effects](docs/spatial-effects.md) |
|
|
96
|
+
| **Hyperparameters** | Empirical Bayes (type-II ML), MAP-II priors, bounds | [empirical bayes](docs/empirical-bayes.md) |
|
|
97
|
+
| **Integration** | INLA-style grid quadrature, simplified/full-Laplace marginals, DIC/WAIC/CPO/PIT | [INLA](docs/inla.md) |
|
|
98
|
+
| **Prediction** | fit-row and out-of-sample `result.predict(new_data)` | [prediction](docs/prediction.md) |
|
|
99
|
+
| **Data boundary** | Pandas, or Spark / Databricks | [spark](docs/spark.md) |
|
|
100
|
+
|
|
101
|
+
## Documentation
|
|
102
|
+
|
|
103
|
+
Full docs: **https://ardea00.github.io/pylgm/** — or browse the
|
|
104
|
+
[`docs/`](docs/) folder. Start with the [index](docs/index.md).
|
|
105
|
+
|
|
106
|
+
## Scope and roadmap
|
|
107
|
+
|
|
108
|
+
pyLGM 0.3 is a bounded foundation release. What is and isn't in it, and where
|
|
109
|
+
it's going, are documented in the [roadmap](docs/roadmap.md) and the
|
|
110
|
+
[internals / release policy](docs/internals.md) page.
|
|
111
|
+
|
|
112
|
+
## Development
|
|
113
|
+
|
|
114
|
+
See [docs/development.md](docs/development.md). License: [MIT](LICENSE).
|
pylgm-0.3.0/README.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# pyLGM
|
|
2
|
+
|
|
3
|
+
General-purpose **latent Gaussian models** for Python — the model class behind
|
|
4
|
+
INLA. Fit fixed effects, random effects, temporal (RW/AR1) and spatial (CAR)
|
|
5
|
+
structure under Gaussian, Poisson, or Bernoulli likelihoods, from a Pandas (or
|
|
6
|
+
Spark) DataFrame, with exact-Gaussian and Laplace inference engines, empirical
|
|
7
|
+
Bayes / MAP-II hyperparameter estimation, and INLA-style posterior integration.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install pylgm
|
|
13
|
+
pip install "pylgm[spark]" # optional: Spark data boundary
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Requires Python ≥ 3.11.
|
|
17
|
+
|
|
18
|
+
## 30-second example
|
|
19
|
+
|
|
20
|
+
A Poisson model with a per-region random intercept, fit with the Laplace engine:
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
import pandas as pd
|
|
24
|
+
from pylgm import Fixed, IID, LGM, Poisson
|
|
25
|
+
|
|
26
|
+
# Counts of events per region over time, with a covariate x.
|
|
27
|
+
frame = pd.DataFrame({
|
|
28
|
+
"region": ["north", "north", "north", "south", "south", "south"],
|
|
29
|
+
"time": [1, 2, 3, 1, 2, 3],
|
|
30
|
+
"x": [0.0, 0.5, 1.0, 0.0, 0.5, 1.0],
|
|
31
|
+
"count": [3, 5, 8, 2, 3, 5],
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
model = LGM(
|
|
35
|
+
response="count",
|
|
36
|
+
likelihood=Poisson(), # canonical log link
|
|
37
|
+
predictor=Fixed("1 + x") # fixed effects
|
|
38
|
+
+ IID("region", index="region", precision=2.0), # random intercept per region
|
|
39
|
+
panel=("region",),
|
|
40
|
+
time="time",
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
result = model.fit(frame, engine="laplace")
|
|
44
|
+
print("fitted_mean:", result.fitted_mean.round(3).tolist())
|
|
45
|
+
# fitted_mean: [3.254, 4.986, 8.15, 2.201, 3.373, 5.513]
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The same model can be declared in YAML and loaded with `pylgm.config.load_model`.
|
|
49
|
+
See the [general LGM example](examples/general_lgm/README.md), which fits the
|
|
50
|
+
same data through both the Python and YAML frontends, and the other 13 runnable
|
|
51
|
+
scripts under [`examples/`](examples/).
|
|
52
|
+
|
|
53
|
+
## What's in the box
|
|
54
|
+
|
|
55
|
+
| Area | What you get | Docs |
|
|
56
|
+
|---|---|---|
|
|
57
|
+
| **Likelihoods** | Gaussian (exact), Poisson & Bernoulli (Laplace) | [likelihoods](docs/likelihoods.md) |
|
|
58
|
+
| **Effects** | `Fixed`, `IID`, `RW1`/`RW2`, stationary `AR1` | [effects](docs/effects.md) |
|
|
59
|
+
| **Spatial** | `Besag` (ICAR), `ProperCAR` (with ρ), `BYM2` (with φ) | [spatial effects](docs/spatial-effects.md) |
|
|
60
|
+
| **Hyperparameters** | Empirical Bayes (type-II ML), MAP-II priors, bounds | [empirical bayes](docs/empirical-bayes.md) |
|
|
61
|
+
| **Integration** | INLA-style grid quadrature, simplified/full-Laplace marginals, DIC/WAIC/CPO/PIT | [INLA](docs/inla.md) |
|
|
62
|
+
| **Prediction** | fit-row and out-of-sample `result.predict(new_data)` | [prediction](docs/prediction.md) |
|
|
63
|
+
| **Data boundary** | Pandas, or Spark / Databricks | [spark](docs/spark.md) |
|
|
64
|
+
|
|
65
|
+
## Documentation
|
|
66
|
+
|
|
67
|
+
Full docs: **https://ardea00.github.io/pylgm/** — or browse the
|
|
68
|
+
[`docs/`](docs/) folder. Start with the [index](docs/index.md).
|
|
69
|
+
|
|
70
|
+
## Scope and roadmap
|
|
71
|
+
|
|
72
|
+
pyLGM 0.3 is a bounded foundation release. What is and isn't in it, and where
|
|
73
|
+
it's going, are documented in the [roadmap](docs/roadmap.md) and the
|
|
74
|
+
[internals / release policy](docs/internals.md) page.
|
|
75
|
+
|
|
76
|
+
## Development
|
|
77
|
+
|
|
78
|
+
See [docs/development.md](docs/development.md). License: [MIT](LICENSE).
|