jmstate 0.1.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.
Files changed (55) hide show
  1. jmstate-0.1.0/.gitignore +115 -0
  2. jmstate-0.1.0/.gitlab-ci.yml +39 -0
  3. jmstate-0.1.0/LICENSE +21 -0
  4. jmstate-0.1.0/PKG-INFO +13 -0
  5. jmstate-0.1.0/README.md +43 -0
  6. jmstate-0.1.0/docs/Makefile +20 -0
  7. jmstate-0.1.0/docs/make.bat +35 -0
  8. jmstate-0.1.0/docs/source/_static/.gitkeep +0 -0
  9. jmstate-0.1.0/docs/source/_templates/autosummary/class.rst +8 -0
  10. jmstate-0.1.0/docs/source/conf.py +46 -0
  11. jmstate-0.1.0/docs/source/functions.rst +23 -0
  12. jmstate-0.1.0/docs/source/index.rst +10 -0
  13. jmstate-0.1.0/docs/source/jobs.rst +28 -0
  14. jmstate-0.1.0/docs/source/model.rst +13 -0
  15. jmstate-0.1.0/docs/source/modules.rst +14 -0
  16. jmstate-0.1.0/docs/source/typedefs.rst +26 -0
  17. jmstate-0.1.0/docs/source/utils.rst +17 -0
  18. jmstate-0.1.0/jmstate/__init__.py +106 -0
  19. jmstate-0.1.0/jmstate/functions/__init__.py +26 -0
  20. jmstate-0.1.0/jmstate/functions/_base_hazards.py +358 -0
  21. jmstate-0.1.0/jmstate/functions/_individual_effects.py +75 -0
  22. jmstate-0.1.0/jmstate/functions/_regression_and_link.py +102 -0
  23. jmstate-0.1.0/jmstate/jobs/__init__.py +27 -0
  24. jmstate-0.1.0/jmstate/jobs/_computation.py +227 -0
  25. jmstate-0.1.0/jmstate/jobs/_fitting.py +215 -0
  26. jmstate-0.1.0/jmstate/jobs/_logging.py +84 -0
  27. jmstate-0.1.0/jmstate/jobs/_prediction.py +336 -0
  28. jmstate-0.1.0/jmstate/jobs/_projection.py +165 -0
  29. jmstate-0.1.0/jmstate/jobs/_stopping.py +401 -0
  30. jmstate-0.1.0/jmstate/model/__init__.py +5 -0
  31. jmstate-0.1.0/jmstate/model/_base.py +499 -0
  32. jmstate-0.1.0/jmstate/model/_cache.py +59 -0
  33. jmstate-0.1.0/jmstate/model/_hazard.py +406 -0
  34. jmstate-0.1.0/jmstate/model/_longitudinal.py +41 -0
  35. jmstate-0.1.0/jmstate/model/_prior.py +32 -0
  36. jmstate-0.1.0/jmstate/model/_sampler.py +142 -0
  37. jmstate-0.1.0/jmstate/typedefs/__init__.py +33 -0
  38. jmstate-0.1.0/jmstate/typedefs/_data.py +328 -0
  39. jmstate-0.1.0/jmstate/typedefs/_defaults.py +40 -0
  40. jmstate-0.1.0/jmstate/typedefs/_defs.py +422 -0
  41. jmstate-0.1.0/jmstate/typedefs/_params.py +221 -0
  42. jmstate-0.1.0/jmstate/typedefs/_validators.py +120 -0
  43. jmstate-0.1.0/jmstate/utils/__init__.py +7 -0
  44. jmstate-0.1.0/jmstate/utils/_checks.py +150 -0
  45. jmstate-0.1.0/jmstate/utils/_dtype.py +31 -0
  46. jmstate-0.1.0/jmstate/utils/_linalg.py +223 -0
  47. jmstate-0.1.0/jmstate/utils/_misc.py +85 -0
  48. jmstate-0.1.0/jmstate/utils/_surv.py +171 -0
  49. jmstate-0.1.0/jmstate.egg-info/PKG-INFO +13 -0
  50. jmstate-0.1.0/jmstate.egg-info/SOURCES.txt +53 -0
  51. jmstate-0.1.0/jmstate.egg-info/dependency_links.txt +1 -0
  52. jmstate-0.1.0/jmstate.egg-info/requires.txt +5 -0
  53. jmstate-0.1.0/jmstate.egg-info/top_level.txt +1 -0
  54. jmstate-0.1.0/pyproject.toml +41 -0
  55. jmstate-0.1.0/setup.cfg +4 -0
@@ -0,0 +1,115 @@
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
+ .hypothesis/
50
+ .pytest_cache/
51
+
52
+ # Translations
53
+ *.mo
54
+ *.pot
55
+
56
+ # Django stuff:
57
+ *.log
58
+ local_settings.py
59
+ db.sqlite3
60
+
61
+ # Flask stuff:
62
+ instance/
63
+ .webassets-cache
64
+
65
+ # Scrapy stuff:
66
+ .scrapy
67
+
68
+ # Sphinx documentation
69
+ docs/_build/
70
+
71
+ # PyBuilder
72
+ target/
73
+
74
+ # Jupyter Notebook
75
+ .ipynb_checkpoints
76
+
77
+ # IPython
78
+ profile_default/
79
+ ipython_config.py
80
+
81
+ # pyenv
82
+ .python-version
83
+
84
+ # celery beat schedule file
85
+ celerybeat-schedule
86
+
87
+ # SageMath parsed files
88
+ *.sage.py
89
+
90
+ # Environments
91
+ .env
92
+ .venv
93
+ env/
94
+ venv/
95
+ ENV/
96
+ env.bak/
97
+ venv.bak/
98
+
99
+ # Spyder project settings
100
+ .spyderproject
101
+ .spyproject
102
+
103
+ # Rope project settings
104
+ .ropeproject
105
+
106
+ # mkdocs documentation
107
+ /site
108
+
109
+ # mypy
110
+ .mypy_cache/
111
+ .dmypy.json
112
+ dmypy.json
113
+
114
+ # Pyre type checker
115
+ .pyre/
@@ -0,0 +1,39 @@
1
+ stages:
2
+ - lint
3
+ - deploy
4
+ - publish
5
+
6
+ lint:
7
+ image: python:latest
8
+ stage: lint
9
+ script:
10
+ - pip install ruff
11
+ - ruff format jmstate
12
+ - ruff check jmstate
13
+ rules:
14
+ - if: $CI_COMMIT_BRANCH
15
+
16
+ pages:
17
+ image: python:latest
18
+ stage: deploy
19
+ script:
20
+ - apt-get update && apt-get install -y git
21
+ - pip install sphinx furo
22
+ - pip install . --extra-index-url https://download.pytorch.org/whl/cpu
23
+ - sphinx-build -b html docs/source public
24
+ artifacts:
25
+ paths:
26
+ - public
27
+ rules:
28
+ - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
29
+
30
+ publish-to-pypi:
31
+ image: python:latest
32
+ stage: publish
33
+ script:
34
+ - python -m pip install --upgrade pip build twine setuptools-scm
35
+ - python -m build
36
+ - TWINE_PASSWORD=${PYPI_TOKEN} TWINE_USERNAME=__token__ python -m twine upload --verbose dist/*
37
+ rules:
38
+ - if: '$CI_COMMIT_TAG =~ /^v.*$/'
39
+
jmstate-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Felix Laplante <felixlaplante0@proton.me>
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.
jmstate-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,13 @@
1
+ Metadata-Version: 2.4
2
+ Name: jmstate
3
+ Version: 0.1.0
4
+ Summary: Joint modeling with automatic differentiation
5
+ Author-email: Félix Laplante <felixlaplante0@proton.me>
6
+ Requires-Python: >=3.10
7
+ License-File: LICENSE
8
+ Requires-Dist: torch
9
+ Requires-Dist: numpy
10
+ Requires-Dist: tqdm
11
+ Requires-Dist: pydantic
12
+ Requires-Dist: xxhash
13
+ Dynamic: license-file
@@ -0,0 +1,43 @@
1
+ # 📦 jmstate
2
+
3
+ **jmstate** is a Python package for **multi-state nonlinear joint modeling**.
4
+ It leverages **PyTorch** for automatic differentiation and vectorized computation, making it efficient and scalable. The package provides a flexible framework where you can use **neural networks as regression and link functions**, while still offering simpler built-in options like parametric baseline hazards.
5
+
6
+ With **jmstate**, you can model longitudinal data jointly with multi-state transitions (e.g. health progression), capture nonlinear effects, and perform inference in complex real-world settings.
7
+
8
+ 👉 Full documentation, tutorials, and API reference are hosted here:
9
+ [**jmstate Documentation**](https://felixlaplante0.gitlab.io/jmstate)
10
+
11
+ ---
12
+
13
+ ## ✨ Features
14
+
15
+ - **Multi-State Joint Modeling**
16
+ Supports subjects moving through multiple states with transition intensities that depend on longitudinal trajectories and covariates.
17
+
18
+ - **Nonlinear Flexibility**
19
+ Use neural networks (or any PyTorch model) as regression or link functions.
20
+
21
+ - **Built-in Tools**
22
+ Includes default baseline hazards, regression, link functions, and analysis utilities.
23
+
24
+ - **Automatic Differentiation & GPU Support**
25
+ Powered by PyTorch for efficient gradient computation and vectorization.
26
+
27
+ - **Analysis & Visualization**
28
+ Tools for state occupancy probabilities, hazard estimation, and residual diagnostics.
29
+
30
+ ---
31
+
32
+ ## 🚀 Installation
33
+
34
+ ```bash
35
+ pip install jmstate
36
+ ```
37
+
38
+ ---
39
+
40
+ ## 📖 Learn More
41
+
42
+ For tutorials, API reference, visit the official site:
43
+ 👉 [jmstate Documentation](https://felixlaplante0.gitlab.io/jmstate)
@@ -0,0 +1,20 @@
1
+ # Minimal makefile for Sphinx documentation
2
+ #
3
+
4
+ # You can set these variables from the command line, and also
5
+ # from the environment for the first two.
6
+ SPHINXOPTS ?=
7
+ SPHINXBUILD ?= sphinx-build
8
+ SOURCEDIR = source
9
+ BUILDDIR = build
10
+
11
+ # Put it first so that "make" without argument is like "make help".
12
+ help:
13
+ @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14
+
15
+ .PHONY: help Makefile
16
+
17
+ # Catch-all target: route all unknown targets to Sphinx using the new
18
+ # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19
+ %: Makefile
20
+ @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@@ -0,0 +1,35 @@
1
+ @ECHO OFF
2
+
3
+ pushd %~dp0
4
+
5
+ REM Command file for Sphinx documentation
6
+
7
+ if "%SPHINXBUILD%" == "" (
8
+ set SPHINXBUILD=sphinx-build
9
+ )
10
+ set SOURCEDIR=source
11
+ set BUILDDIR=build
12
+
13
+ %SPHINXBUILD% >NUL 2>NUL
14
+ if errorlevel 9009 (
15
+ echo.
16
+ echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17
+ echo.installed, then set the SPHINXBUILD environment variable to point
18
+ echo.to the full path of the 'sphinx-build' executable. Alternatively you
19
+ echo.may add the Sphinx directory to PATH.
20
+ echo.
21
+ echo.If you don't have Sphinx installed, grab it from
22
+ echo.https://www.sphinx-doc.org/
23
+ exit /b 1
24
+ )
25
+
26
+ if "%1" == "" goto help
27
+
28
+ %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29
+ goto end
30
+
31
+ :help
32
+ %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33
+
34
+ :end
35
+ popd
File without changes
@@ -0,0 +1,8 @@
1
+ {{ fullname | escape | underline}}
2
+
3
+ .. currentmodule:: {{ module }}
4
+
5
+ .. autoclass:: {{ objname }}
6
+ :members:
7
+
8
+ .. automethod:: __init__
@@ -0,0 +1,46 @@
1
+ # Configuration file for the Sphinx documentation builder.
2
+ #
3
+ # For the full list of built-in configuration values, see the documentation:
4
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html
5
+
6
+ # -- Project information -----------------------------------------------------
7
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
8
+
9
+
10
+ import os
11
+
12
+ release = os.getenv("CI_COMMIT_TAG", "v0.0.0")
13
+ version = release.lstrip("v")
14
+
15
+
16
+ project = "jmstate"
17
+ copyright = "2025, Félix Laplante"
18
+ author = "Félix Laplante"
19
+
20
+ # -- General configuration ---------------------------------------------------
21
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
22
+
23
+ extensions = [
24
+ "sphinx.ext.autodoc",
25
+ "sphinx.ext.napoleon",
26
+ "sphinx.ext.viewcode",
27
+ "sphinx.ext.autosummary",
28
+ ]
29
+
30
+ templates_path = ["_templates"]
31
+ exclude_patterns = []
32
+
33
+ autodoc_member_order = "bysource"
34
+ autodoc_typehints = "description"
35
+ autodoc_typehints_format = "short"
36
+ autodoc_inherit_docstrings = True
37
+ autosummary_generate = True
38
+ add_module_names = False
39
+ napoleon_use_ivar = True
40
+ napoleon_attr_annotations = True
41
+
42
+ # -- Options for HTML output -------------------------------------------------
43
+ # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
44
+
45
+ html_theme = "furo"
46
+ html_static_path = ["_static"]
@@ -0,0 +1,23 @@
1
+ Functions
2
+ =========
3
+
4
+ .. automodule:: jmstate.functions
5
+ :no-members:
6
+ :no-undoc-members:
7
+ :no-index:
8
+
9
+ .. autosummary::
10
+ :toctree: generated/
11
+ :recursive:
12
+
13
+ Exponential
14
+ Gompertz
15
+ LogNormal
16
+ Net
17
+ Weibull
18
+ clock_forward
19
+ clock_reset
20
+ gamma_plus_b
21
+ gamma_x_plus_b
22
+ identity
23
+ linear
@@ -0,0 +1,10 @@
1
+ Welcome to jmstate's Documentation!
2
+ ===================================
3
+
4
+ This is a comprehensive guide to the jmstate package, a tool for multistate joint modeling with PyTorch.
5
+
6
+ .. toctree::
7
+ :maxdepth: 2
8
+ :caption: Contents:
9
+
10
+ modules
@@ -0,0 +1,28 @@
1
+ Jobs
2
+ ====
3
+
4
+ .. automodule:: jmstate.jobs
5
+ :no-members:
6
+ :no-undoc-members:
7
+ :no-index:
8
+
9
+ .. autosummary::
10
+ :toctree: generated/
11
+ :recursive:
12
+
13
+ AdamL1Proximal
14
+ ComputeCriteria
15
+ ComputeEBEs
16
+ ComputeFIM
17
+ Fit
18
+ GradStop
19
+ LogParamsHistory
20
+ MCMCDiagnostics
21
+ NoStop
22
+ ParamStop
23
+ PredictSurvLogps
24
+ PredictTrajectories
25
+ PredictY
26
+ Scheduling
27
+ SwitchParams
28
+ ValueStop
@@ -0,0 +1,13 @@
1
+ Model
2
+ =====
3
+
4
+ .. automodule:: jmstate.model
5
+ :members:
6
+ :undoc-members:
7
+ :no-index:
8
+
9
+ .. autosummary::
10
+ :toctree: generated/
11
+ :recursive:
12
+
13
+ MultiStateJointModel
@@ -0,0 +1,14 @@
1
+ API Reference
2
+ =============
3
+
4
+ This page provides an overview of the main modules and their members within the `jmstate` package.
5
+
6
+ .. toctree::
7
+ :maxdepth: 2
8
+ :caption: Subpackages:
9
+
10
+ model
11
+ typedefs
12
+ functions
13
+ jobs
14
+ utils
@@ -0,0 +1,26 @@
1
+ Typedefs
2
+ ========
3
+
4
+ .. automodule:: jmstate.typedefs
5
+ :no-members:
6
+ :no-undoc-members:
7
+ :no-index:
8
+
9
+ .. autosummary::
10
+ :toctree: generated/
11
+ :recursive:
12
+
13
+ BaseHazardFn
14
+ BucketData
15
+ ClockMethod
16
+ IndividualEffectsFn
17
+ Info
18
+ Job
19
+ LinkFn
20
+ MatRepr
21
+ Metrics
22
+ ModelData
23
+ ModelDesign
24
+ ModelParams
25
+ RegressionFn
26
+ SampleData
@@ -0,0 +1,17 @@
1
+ Utils
2
+ =====
3
+
4
+ .. automodule:: jmstate.utils
5
+ :no-members:
6
+ :no-undoc-members:
7
+ :no-index:
8
+
9
+ .. autosummary::
10
+ :toctree: generated/
11
+ :recursive:
12
+
13
+ build_buckets
14
+ cov_from_repr
15
+ get_dtype
16
+ repr_from_cov
17
+ set_dtype
@@ -0,0 +1,106 @@
1
+ """multistate joint modeling package.
2
+
3
+ This package provides tools for multistate joint modeling with PyTorch.
4
+ """
5
+
6
+ from .functions import (
7
+ Exponential,
8
+ Gompertz,
9
+ LogNormal,
10
+ Net,
11
+ Weibull,
12
+ clock_forward,
13
+ clock_reset,
14
+ gamma_plus_b,
15
+ gamma_x_plus_b,
16
+ identity,
17
+ linear,
18
+ )
19
+ from .jobs import (
20
+ AdamL1Proximal,
21
+ ComputeCriteria,
22
+ ComputeEBEs,
23
+ ComputeFIM,
24
+ Fit,
25
+ GradStop,
26
+ LogParamsHistory,
27
+ MCMCDiagnostics,
28
+ ParamStop,
29
+ PredictSurvLogps,
30
+ PredictTrajectories,
31
+ PredictY,
32
+ Scheduling,
33
+ SwitchParams,
34
+ ValueStop,
35
+ )
36
+ from .model._base import MultiStateJointModel
37
+ from .typedefs import (
38
+ BaseHazardFn,
39
+ BucketData,
40
+ ClockMethod,
41
+ IndividualEffectsFn,
42
+ Info,
43
+ Job,
44
+ LinkFn,
45
+ MatRepr,
46
+ Metrics,
47
+ ModelData,
48
+ ModelDesign,
49
+ ModelParams,
50
+ RegressionFn,
51
+ SampleData,
52
+ )
53
+ from .utils import build_buckets, cov_from_repr, get_dtype, repr_from_cov, set_dtype
54
+
55
+ __author__ = "Félix Laplante"
56
+ __email__ = "felixlaplante0@gmail.com"
57
+ __license__ = "MIT"
58
+
59
+ __all__ = [
60
+ "AdamL1Proximal",
61
+ "BaseHazardFn",
62
+ "BucketData",
63
+ "ClockMethod",
64
+ "ComputeCriteria",
65
+ "ComputeEBEs",
66
+ "ComputeFIM",
67
+ "Exponential",
68
+ "Fit",
69
+ "Gompertz",
70
+ "GradStop",
71
+ "IndividualEffectsFn",
72
+ "Info",
73
+ "Job",
74
+ "LinkFn",
75
+ "LogNormal",
76
+ "LogParamsHistory",
77
+ "MCMCDiagnostics",
78
+ "MatRepr",
79
+ "Metrics",
80
+ "ModelData",
81
+ "ModelDesign",
82
+ "ModelParams",
83
+ "MultiStateJointModel",
84
+ "Net",
85
+ "ParamStop",
86
+ "PredictSurvLogps",
87
+ "PredictTrajectories",
88
+ "PredictY",
89
+ "RegressionFn",
90
+ "SampleData",
91
+ "Scheduling",
92
+ "SwitchParams",
93
+ "ValueStop",
94
+ "Weibull",
95
+ "build_buckets",
96
+ "clock_forward",
97
+ "clock_reset",
98
+ "cov_from_repr",
99
+ "gamma_plus_b",
100
+ "gamma_x_plus_b",
101
+ "get_dtype",
102
+ "identity",
103
+ "linear",
104
+ "repr_from_cov",
105
+ "set_dtype",
106
+ ]
@@ -0,0 +1,26 @@
1
+ """Functions for the jmstate package."""
2
+
3
+ from ._base_hazards import (
4
+ Exponential,
5
+ Gompertz,
6
+ LogNormal,
7
+ Weibull,
8
+ clock_forward,
9
+ clock_reset,
10
+ )
11
+ from ._individual_effects import gamma_plus_b, gamma_x_plus_b, identity
12
+ from ._regression_and_link import Net, linear
13
+
14
+ __all__ = [
15
+ "Exponential",
16
+ "Gompertz",
17
+ "LogNormal",
18
+ "Net",
19
+ "Weibull",
20
+ "clock_forward",
21
+ "clock_reset",
22
+ "gamma_plus_b",
23
+ "gamma_x_plus_b",
24
+ "identity",
25
+ "linear",
26
+ ]