survml 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.
survml-1.0/.gitignore ADDED
@@ -0,0 +1,57 @@
1
+ __pycache__/
2
+ *.pyc
3
+ *.egg-info/
4
+ dist/
5
+ build/
6
+ .pytest_cache/
7
+ .ruff_cache/
8
+ docs/_build/
9
+ docs/auto_examples/
10
+ docs/gen_modules/
11
+ docs/sg_execution_times.rst
12
+ book/figures/
13
+ book/*.aux
14
+ book/*.log
15
+ book/*.out
16
+ book/*.toc
17
+ book/*.bbl
18
+ book/*.bcf
19
+ book/*.blg
20
+ book/*.run.xml
21
+ book/*.idx
22
+ book/*.ilg
23
+ book/*.ind
24
+ book/*.fls
25
+ book/*.fdb_latexmk
26
+ book/*.synctex.gz
27
+ book/main.pdf
28
+ *.ipynb_checkpoints
29
+ book/_check_tmp/
30
+ book/_check.tex
31
+ docs/_build/
32
+ docs/api/generated/
33
+ docs/_build_log.txt
34
+ book/_build/
35
+ .coverage
36
+ book/_build_new/
37
+ book/_check_*.tex
38
+ book/cover/*.aux
39
+ book/cover/*.log
40
+ book/cover/*.fls
41
+ book/cover/*.fdb_latexmk
42
+ book/cover/cover_*.pdf
43
+ book/cover/logo.svg
44
+ *.blg
45
+ book/_build_epub/
46
+ book/_build_web/
47
+ docs/_gallery_src/
48
+
49
+ # generated by docs/build_api_pages.py and the gallery
50
+ docs/api/generated/
51
+ # LaTeX intermediates of the cover
52
+ book/cover/*.aux
53
+ book/cover/*.log
54
+ book/*.lof
55
+ book/*.run.xml
56
+ book/*.blg
57
+ __pycache__/
@@ -0,0 +1,25 @@
1
+ # Changelog
2
+
3
+ ## 1.0 (December 2026)
4
+
5
+ First release.
6
+
7
+ * Classical estimators with case weights: Kaplan–Meier (Greenwood variance, log–log intervals, delayed entry),
8
+ Nelson–Aalen, Aalen–Johansen, k-sample log-rank tests with Fleming–Harrington weights, pairwise tests with
9
+ Holm's correction, bootstrap bands (`survml.core`).
10
+ * Cluster-weighted mixtures of local survival models with Gaussian and categorical gates fitted by EM, with
11
+ censoring in the likelihood, Weibull, exponential, log-normal and log-logistic local models, AIC/BIC selection,
12
+ Takagi–Sugeno fuzzy rules and membership-weighted Kaplan–Meier validation (`survml.mixture`).
13
+ * Period-wise frequent itemsets of triggering events, association rules to competing outcomes and cumulative
14
+ incidence functions (cause-specific and subdistribution forms) for patterns of itemsets (`survml.itemsets`).
15
+ * Frequent sequences and sequential rules with time-dependent confidences, chained continuations, bootstrap
16
+ bands, log-rank comparisons, predictions — and a censoring-aware Aalen–Johansen estimator of the confidence
17
+ functions (new) (`survml.sequences`, `survml.patterns`).
18
+ * Root causes of long durations by Cox regression with factors, likelihood-ratio tests, Holm-adjusted Wald
19
+ tests, proportional-hazards checks and level durations (`survml.changeover`).
20
+ * Fine–Gray regression with robust standard errors (`survml.competing`), pseudo-observation regression for
21
+ survival probabilities, restricted means and cumulative incidences (`survml.pseudo`), RMST tests and restricted
22
+ mean time lost (`survml.restricted`), logistic–Weibull mixture cure models (`survml.cure`), survival stacking with
23
+ any classifier (`survml.stacking`), conformal lower prediction bounds with fixed and adaptive cut-offs
24
+ (`survml.conformal`), concordance, IPCW Brier score and D-calibration (`survml.metrics`).
25
+ * Verified loaders of nine public data sets, simulators with known truth and plots in the house style.
@@ -0,0 +1,67 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use survml, please cite it as below, together with the original publications of the methods you use."
3
+ type: software
4
+ title: "survml: integrated survival analysis and machine learning in Python"
5
+ version: "1.0"
6
+ date-released: 2026-12-04
7
+ license: MIT
8
+ repository-code: "https://github.com/ComplexSystemsIntelligence/survml"
9
+ url: "https://complexsystemsintelligence.github.io/survml"
10
+ authors:
11
+ - family-names: Csalódi
12
+ given-names: Róbert
13
+ affiliation: "University of Pannonia, Veszprém, Hungary"
14
+ - family-names: Abonyi
15
+ given-names: János
16
+ affiliation: "University of Pannonia, Veszprém, Hungary"
17
+ orcid: "https://orcid.org/0000-0001-8593-1493"
18
+ keywords:
19
+ - survival analysis
20
+ - competing risks
21
+ - Weibull mixture
22
+ - fuzzy rules
23
+ - frequent itemsets
24
+ - sequential pattern mining
25
+ - Fine-Gray
26
+ - pseudo-observations
27
+ - cure model
28
+ - conformal prediction
29
+ references:
30
+ - type: thesis
31
+ title: "Machine learning supported survival analysis"
32
+ authors:
33
+ - family-names: Csalódi
34
+ given-names: Róbert
35
+ year: 2024
36
+ institution:
37
+ name: "University of Pannonia"
38
+ doi: 10.18136/PE.2024.893
39
+ - type: article
40
+ title: "Mixture of survival analysis models — cluster-weighted Weibull distributions"
41
+ authors:
42
+ - family-names: Csalódi
43
+ given-names: Róbert
44
+ - family-names: Bagyura
45
+ given-names: Zsolt
46
+ - family-names: Abonyi
47
+ given-names: János
48
+ journal: "IEEE Access"
49
+ volume: 9
50
+ start: 152288
51
+ end: 152299
52
+ year: 2021
53
+ doi: 10.1109/ACCESS.2021.3127576
54
+ - type: article
55
+ title: "Time-dependent frequent sequence mining-based survival analysis"
56
+ authors:
57
+ - family-names: Csalódi
58
+ given-names: Róbert
59
+ - family-names: Bagyura
60
+ given-names: Zsolt
61
+ - family-names: Vathy-Fogarassy
62
+ given-names: Ágnes
63
+ - family-names: Abonyi
64
+ given-names: János
65
+ journal: "Knowledge-Based Systems"
66
+ year: 2024
67
+ doi: 10.1016/j.knosys.2024.111885
survml-1.0/LICENSE ADDED
@@ -0,0 +1,24 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Róbert Csalódi, János Abonyi
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.
22
+
23
+ The companion book in the book/ directory is licensed under the Creative
24
+ Commons Attribution 4.0 International License (CC BY 4.0).
survml-1.0/PKG-INFO ADDED
@@ -0,0 +1,166 @@
1
+ Metadata-Version: 2.5
2
+ Name: survml
3
+ Version: 1.0
4
+ Summary: Integrated survival analysis and machine learning: cluster-weighted Weibull mixtures with fuzzy rules, itemset- and sequence-based time-dependent rules for competing risks, Fine-Gray regression, pseudo-observations, RMST, mixture cure models, survival stacking and conformal lower prediction bounds.
5
+ Project-URL: Homepage, https://github.com/ComplexSystemsIntelligence/survml
6
+ Project-URL: Documentation, https://complexsystemsintelligence.github.io/survml
7
+ Project-URL: Repository, https://github.com/ComplexSystemsIntelligence/survml
8
+ Project-URL: Issues, https://github.com/ComplexSystemsIntelligence/survml/issues
9
+ Author: Róbert Csalódi
10
+ Author-email: János Abonyi <janos@abonyilab.com>
11
+ Maintainer-email: János Abonyi <janos@abonyilab.com>
12
+ License-Expression: MIT
13
+ License-File: LICENSE
14
+ Keywords: Fine-Gray,Weibull mixture,competing risks,conformal prediction,cure model,expectation maximization,frequent itemsets,fuzzy rules,process mining,pseudo-observations,restricted mean survival time,sequential pattern mining,sequential rules,survival analysis,survival stacking,time-to-event
15
+ Classifier: Development Status :: 5 - Production/Stable
16
+ Classifier: Intended Audience :: Science/Research
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Topic :: Scientific/Engineering
25
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
26
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
27
+ Classifier: Topic :: Scientific/Engineering :: Medical Science Apps.
28
+ Requires-Python: >=3.10
29
+ Requires-Dist: lifelines>=0.27
30
+ Requires-Dist: matplotlib>=3.7
31
+ Requires-Dist: numpy>=1.24
32
+ Requires-Dist: pandas>=2.0
33
+ Requires-Dist: scikit-learn>=1.3
34
+ Requires-Dist: scipy>=1.11
35
+ Provides-Extra: dev
36
+ Requires-Dist: build; extra == 'dev'
37
+ Requires-Dist: myst-parser; extra == 'dev'
38
+ Requires-Dist: numpydoc; extra == 'dev'
39
+ Requires-Dist: pydata-sphinx-theme; extra == 'dev'
40
+ Requires-Dist: pytest-cov; extra == 'dev'
41
+ Requires-Dist: pytest>=7; extra == 'dev'
42
+ Requires-Dist: ruff; extra == 'dev'
43
+ Requires-Dist: scikit-survival>=0.22; extra == 'dev'
44
+ Requires-Dist: sphinx-copybutton; extra == 'dev'
45
+ Requires-Dist: sphinx-design; extra == 'dev'
46
+ Requires-Dist: sphinx-gallery>=0.15; extra == 'dev'
47
+ Requires-Dist: sphinx>=7; extra == 'dev'
48
+ Requires-Dist: twine; extra == 'dev'
49
+ Provides-Extra: docs
50
+ Requires-Dist: myst-parser; extra == 'docs'
51
+ Requires-Dist: numpydoc; extra == 'docs'
52
+ Requires-Dist: pydata-sphinx-theme; extra == 'docs'
53
+ Requires-Dist: sphinx-copybutton; extra == 'docs'
54
+ Requires-Dist: sphinx-design; extra == 'docs'
55
+ Requires-Dist: sphinx-gallery>=0.15; extra == 'docs'
56
+ Requires-Dist: sphinx>=7; extra == 'docs'
57
+ Provides-Extra: test
58
+ Requires-Dist: pytest-cov; extra == 'test'
59
+ Requires-Dist: pytest>=7; extra == 'test'
60
+ Requires-Dist: scikit-survival>=0.22; extra == 'test'
61
+ Description-Content-Type: text/markdown
62
+
63
+ <p align="center"><img src="https://raw.githubusercontent.com/ComplexSystemsIntelligence/survml/main/docs/_static/banner.png" alt="survml: integrated survival analysis and machine learning in Python"></p>
64
+
65
+ # survml: integrated survival analysis and machine learning
66
+
67
+ [![tests](https://github.com/ComplexSystemsIntelligence/survml/actions/workflows/ci.yml/badge.svg)](https://github.com/ComplexSystemsIntelligence/survml/actions/workflows/ci.yml)
68
+ [![docs](https://img.shields.io/badge/docs-gallery%20%2B%20API-285780)](https://complexsystemsintelligence.github.io/survml)
69
+ [![book](https://img.shields.io/badge/book-web%20%C2%B7%20PDF-D55E00)](https://complexsystemsintelligence.github.io/survml/book/)
70
+ [![PyPI](https://img.shields.io/pypi/v/survml.svg)](https://pypi.org/project/survml/)
71
+ [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/ComplexSystemsIntelligence/survml/blob/main/notebooks/survml_tour.ipynb)
72
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/ComplexSystemsIntelligence/survml/blob/main/LICENSE)
73
+
74
+ Survival analysis says *how long* it takes until an event — a failure, a
75
+ dropout, a relapse, the end of a machine setup. On its own it says little
76
+ about *why* some subjects fail early: which groups behave differently, which
77
+ combinations of earlier events trigger the outcome, which pathway leads where
78
+ and how fast. **survml** integrates survival analysis with machine learning
79
+ to answer these questions, following the methodology of the Complex Systems
80
+ Intelligence group of the University of Pannonia
81
+ ([www.abonyilab.com](https://www.abonyilab.com/ai-data-science/survival-analysis)),
82
+ and adds recent survival methods that have no Python implementation
83
+ elsewhere. The classical estimators come from a small weighted core and from
84
+ [lifelines](https://lifelines.readthedocs.io); scikit-learn classifiers plug
85
+ into the learning-based methods.
86
+
87
+ | Module | Contents |
88
+ |---|---|
89
+ | `survml.core` | Kaplan–Meier (weights, delayed entry, Greenwood, log–log CI), Nelson–Aalen, Aalen–Johansen, log-rank tests with Fleming–Harrington weights, pairwise tests, bootstrap bands |
90
+ | `survml.mixture` | **cluster-weighted mixtures of local survival models**: Weibull (or exponential, log-normal, log-logistic) local models with Gaussian and categorical gates, EM with censoring in the likelihood (new), AIC/BIC, Takagi–Sugeno fuzzy rules, weighted Kaplan–Meier validation (Csalódi, Bagyura & Abonyi 2021; Csalódi, Birkner & Abonyi 2021) |
91
+ | `survml.itemsets` | **frequent itemsets of triggering events per period**, association rules to competing outcomes, cumulative incidence in the cause-specific and subdistribution forms, incidences of itemset patterns and predictions (Csalódi & Abonyi 2021) |
92
+ | `survml.sequences` | **frequent sequences and sequential rules with time-dependent confidences**, chained continuations, bootstrap bands, log-rank comparisons, predictions; a censoring-aware Aalen–Johansen confidence function (new) (Csalódi et al. 2024, KBS and MethodsX) |
93
+ | `survml.changeover` | **root causes of long durations**: Cox regression with factors, likelihood-ratio and Holm-adjusted tests, PH check with stratification, level durations (Ruppert, Csalódi & Abonyi 2021) |
94
+ | `survml.competing` | Fine–Gray proportional subdistribution hazards regression with robust standard errors |
95
+ | `survml.pseudo` | jackknife pseudo-observations and GEE regression for survival probabilities, RMST and cumulative incidences |
96
+ | `survml.restricted` | restricted mean survival time with variance, two-sample difference and ratio, restricted mean time lost |
97
+ | `survml.cure` | logistic–Weibull mixture cure model by EM, with observed-information standard errors |
98
+ | `survml.stacking` | survival stacking: any scikit-learn classifier as a discrete-time survival model |
99
+ | `survml.conformal` | conformal lower prediction bounds under Type I censoring, fixed (Candès, Lei & Ren 2023) and adaptive cut-offs (Gui, Hore, Ren & Barber 2024) |
100
+ | `survml.metrics` | Harrell's and Uno's concordance, IPCW Brier score and its integral, D-calibration |
101
+ | `survml.datasets` | verified loaders of public data: Rotterdam, veterans, melanoma, MGUS, SEER prostate, EBMT pathways, PBC visits, capacitor life test, Open University Learning Analytics |
102
+ | `survml.simulate`, `survml.viz` | simulators with known truth; plots in the house style |
103
+
104
+ Neither `lifelines` nor `scikit-survival` fits Fine–Gray models, pseudo-observation
105
+ regression, mixture cure models with covariates, survival stacking or
106
+ conformal survival bounds; the integrated pattern-mining methods were available
107
+ only as MATLAB code.
108
+
109
+ ## Installation
110
+
111
+ ```bash
112
+ pip install survml
113
+ pip install git+https://github.com/ComplexSystemsIntelligence/survml # development version
114
+ ```
115
+
116
+ Python ≥ 3.10; depends on numpy, scipy, pandas, matplotlib, scikit-learn and lifelines.
117
+
118
+ ## Quick start
119
+
120
+ ```python
121
+ import numpy as np, pandas as pd
122
+ import survml as sm
123
+ from survml import datasets, viz
124
+
125
+ # 1. local survival models of breast cancer patients, read as fuzzy rules
126
+ rot = datasets.load_rotterdam()
127
+ Xc = pd.DataFrame({"age": rot.age, "log_pgr": np.log1p(rot.pgr), "log_er": np.log1p(rot.er)})
128
+ Xd = pd.DataFrame({"grade": rot.grade.astype(str), "size": rot["size"], "chemo": rot.chemo.astype(str)})
129
+ mix = sm.ClusterWeightedSurvival(4, reg_covar=0.02, random_state=0).fit(rot.rfs_time / 365.25, rot.rfs_event, Xc, Xd)
130
+ for rule in mix.to_rules():
131
+ print(rule)
132
+ viz.plot_mixture(mix)
133
+
134
+ # 2. time-dependent confidence of patient pathways after transplantation
135
+ log, end, patients = datasets.load_ebmt4()
136
+ seq = sm.FrequentSequenceSurvival(min_support=0.03, terminal=["death"]).fit(log, end=end)
137
+ print(seq.confidence_function(("recovery", "relapse"), grid=[100, 365, 1000], n_boot=100))
138
+
139
+ # 3. competing risks: Fine-Gray regression of progression in MGUS
140
+ mg = datasets.load_mgus2().dropna()
141
+ print(sm.FineGray(cause=1).fit(mg[["age", "male", "hgb", "creat", "mspike"]], mg.etime, mg.event).summary_)
142
+ ```
143
+
144
+ The [gallery](https://complexsystemsintelligence.github.io/survml/auto_examples/index.html)
145
+ has one worked example per method on public data, and the
146
+ [book](https://complexsystemsintelligence.github.io/survml/book.html) explains the
147
+ theory behind every function.
148
+
149
+ ## Citing
150
+
151
+ Please cite the software (`CITATION.cff`) together with the original
152
+ publications of the methods you use:
153
+
154
+ * R. Csalódi, Z. Bagyura, J. Abonyi: Mixture of survival analysis models — cluster-weighted Weibull distributions. *IEEE Access* 9 (2021) 152288–152299. [doi:10.1109/ACCESS.2021.3127576](https://doi.org/10.1109/ACCESS.2021.3127576)
155
+ * R. Csalódi, Z. Birkner, J. Abonyi: Learning interpretable mixture of Weibull distributions. *Data* 6 (2021) 125. [doi:10.3390/data6120125](https://doi.org/10.3390/data6120125)
156
+ * R. Csalódi, J. Abonyi: Integrated survival analysis and frequent pattern mining for course failure-based prediction of student dropout. *Mathematics* 9 (2021) 463. [doi:10.3390/math9050463](https://doi.org/10.3390/math9050463)
157
+ * R. Csalódi, Z. Bagyura, Á. Vathy-Fogarassy, J. Abonyi: Time-dependent frequent sequence mining-based survival analysis. *Knowledge-Based Systems* (2024) 111885. [doi:10.1016/j.knosys.2024.111885](https://doi.org/10.1016/j.knosys.2024.111885)
158
+ * R. Csalódi, Z. Bagyura, J. Abonyi: Time-dependent sequential association rule-based survival analysis: a healthcare application. *MethodsX* (2024) 102535. [doi:10.1016/j.mex.2023.102535](https://doi.org/10.1016/j.mex.2023.102535)
159
+ * T. Ruppert, R. Csalódi, J. Abonyi: Estimation of machine setup and changeover times by survival analysis. *Computers & Industrial Engineering* 153 (2021) 107026. [doi:10.1016/j.cie.2020.107026](https://doi.org/10.1016/j.cie.2020.107026)
160
+ * R. Csalódi: *Machine learning supported survival analysis*. PhD thesis, University of Pannonia (2024). [doi:10.18136/PE.2024.893](https://doi.org/10.18136/PE.2024.893)
161
+
162
+ ## License
163
+
164
+ Code: MIT. Book (`book/`): CC BY 4.0. The research was supported by the
165
+ National Research, Development and Innovation Office of Hungary (NKFIH)
166
+ through the OTKA 143482 project.
survml-1.0/README.md ADDED
@@ -0,0 +1,104 @@
1
+ <p align="center"><img src="https://raw.githubusercontent.com/ComplexSystemsIntelligence/survml/main/docs/_static/banner.png" alt="survml: integrated survival analysis and machine learning in Python"></p>
2
+
3
+ # survml: integrated survival analysis and machine learning
4
+
5
+ [![tests](https://github.com/ComplexSystemsIntelligence/survml/actions/workflows/ci.yml/badge.svg)](https://github.com/ComplexSystemsIntelligence/survml/actions/workflows/ci.yml)
6
+ [![docs](https://img.shields.io/badge/docs-gallery%20%2B%20API-285780)](https://complexsystemsintelligence.github.io/survml)
7
+ [![book](https://img.shields.io/badge/book-web%20%C2%B7%20PDF-D55E00)](https://complexsystemsintelligence.github.io/survml/book/)
8
+ [![PyPI](https://img.shields.io/pypi/v/survml.svg)](https://pypi.org/project/survml/)
9
+ [![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/ComplexSystemsIntelligence/survml/blob/main/notebooks/survml_tour.ipynb)
10
+ [![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/ComplexSystemsIntelligence/survml/blob/main/LICENSE)
11
+
12
+ Survival analysis says *how long* it takes until an event — a failure, a
13
+ dropout, a relapse, the end of a machine setup. On its own it says little
14
+ about *why* some subjects fail early: which groups behave differently, which
15
+ combinations of earlier events trigger the outcome, which pathway leads where
16
+ and how fast. **survml** integrates survival analysis with machine learning
17
+ to answer these questions, following the methodology of the Complex Systems
18
+ Intelligence group of the University of Pannonia
19
+ ([www.abonyilab.com](https://www.abonyilab.com/ai-data-science/survival-analysis)),
20
+ and adds recent survival methods that have no Python implementation
21
+ elsewhere. The classical estimators come from a small weighted core and from
22
+ [lifelines](https://lifelines.readthedocs.io); scikit-learn classifiers plug
23
+ into the learning-based methods.
24
+
25
+ | Module | Contents |
26
+ |---|---|
27
+ | `survml.core` | Kaplan–Meier (weights, delayed entry, Greenwood, log–log CI), Nelson–Aalen, Aalen–Johansen, log-rank tests with Fleming–Harrington weights, pairwise tests, bootstrap bands |
28
+ | `survml.mixture` | **cluster-weighted mixtures of local survival models**: Weibull (or exponential, log-normal, log-logistic) local models with Gaussian and categorical gates, EM with censoring in the likelihood (new), AIC/BIC, Takagi–Sugeno fuzzy rules, weighted Kaplan–Meier validation (Csalódi, Bagyura & Abonyi 2021; Csalódi, Birkner & Abonyi 2021) |
29
+ | `survml.itemsets` | **frequent itemsets of triggering events per period**, association rules to competing outcomes, cumulative incidence in the cause-specific and subdistribution forms, incidences of itemset patterns and predictions (Csalódi & Abonyi 2021) |
30
+ | `survml.sequences` | **frequent sequences and sequential rules with time-dependent confidences**, chained continuations, bootstrap bands, log-rank comparisons, predictions; a censoring-aware Aalen–Johansen confidence function (new) (Csalódi et al. 2024, KBS and MethodsX) |
31
+ | `survml.changeover` | **root causes of long durations**: Cox regression with factors, likelihood-ratio and Holm-adjusted tests, PH check with stratification, level durations (Ruppert, Csalódi & Abonyi 2021) |
32
+ | `survml.competing` | Fine–Gray proportional subdistribution hazards regression with robust standard errors |
33
+ | `survml.pseudo` | jackknife pseudo-observations and GEE regression for survival probabilities, RMST and cumulative incidences |
34
+ | `survml.restricted` | restricted mean survival time with variance, two-sample difference and ratio, restricted mean time lost |
35
+ | `survml.cure` | logistic–Weibull mixture cure model by EM, with observed-information standard errors |
36
+ | `survml.stacking` | survival stacking: any scikit-learn classifier as a discrete-time survival model |
37
+ | `survml.conformal` | conformal lower prediction bounds under Type I censoring, fixed (Candès, Lei & Ren 2023) and adaptive cut-offs (Gui, Hore, Ren & Barber 2024) |
38
+ | `survml.metrics` | Harrell's and Uno's concordance, IPCW Brier score and its integral, D-calibration |
39
+ | `survml.datasets` | verified loaders of public data: Rotterdam, veterans, melanoma, MGUS, SEER prostate, EBMT pathways, PBC visits, capacitor life test, Open University Learning Analytics |
40
+ | `survml.simulate`, `survml.viz` | simulators with known truth; plots in the house style |
41
+
42
+ Neither `lifelines` nor `scikit-survival` fits Fine–Gray models, pseudo-observation
43
+ regression, mixture cure models with covariates, survival stacking or
44
+ conformal survival bounds; the integrated pattern-mining methods were available
45
+ only as MATLAB code.
46
+
47
+ ## Installation
48
+
49
+ ```bash
50
+ pip install survml
51
+ pip install git+https://github.com/ComplexSystemsIntelligence/survml # development version
52
+ ```
53
+
54
+ Python ≥ 3.10; depends on numpy, scipy, pandas, matplotlib, scikit-learn and lifelines.
55
+
56
+ ## Quick start
57
+
58
+ ```python
59
+ import numpy as np, pandas as pd
60
+ import survml as sm
61
+ from survml import datasets, viz
62
+
63
+ # 1. local survival models of breast cancer patients, read as fuzzy rules
64
+ rot = datasets.load_rotterdam()
65
+ Xc = pd.DataFrame({"age": rot.age, "log_pgr": np.log1p(rot.pgr), "log_er": np.log1p(rot.er)})
66
+ Xd = pd.DataFrame({"grade": rot.grade.astype(str), "size": rot["size"], "chemo": rot.chemo.astype(str)})
67
+ mix = sm.ClusterWeightedSurvival(4, reg_covar=0.02, random_state=0).fit(rot.rfs_time / 365.25, rot.rfs_event, Xc, Xd)
68
+ for rule in mix.to_rules():
69
+ print(rule)
70
+ viz.plot_mixture(mix)
71
+
72
+ # 2. time-dependent confidence of patient pathways after transplantation
73
+ log, end, patients = datasets.load_ebmt4()
74
+ seq = sm.FrequentSequenceSurvival(min_support=0.03, terminal=["death"]).fit(log, end=end)
75
+ print(seq.confidence_function(("recovery", "relapse"), grid=[100, 365, 1000], n_boot=100))
76
+
77
+ # 3. competing risks: Fine-Gray regression of progression in MGUS
78
+ mg = datasets.load_mgus2().dropna()
79
+ print(sm.FineGray(cause=1).fit(mg[["age", "male", "hgb", "creat", "mspike"]], mg.etime, mg.event).summary_)
80
+ ```
81
+
82
+ The [gallery](https://complexsystemsintelligence.github.io/survml/auto_examples/index.html)
83
+ has one worked example per method on public data, and the
84
+ [book](https://complexsystemsintelligence.github.io/survml/book.html) explains the
85
+ theory behind every function.
86
+
87
+ ## Citing
88
+
89
+ Please cite the software (`CITATION.cff`) together with the original
90
+ publications of the methods you use:
91
+
92
+ * R. Csalódi, Z. Bagyura, J. Abonyi: Mixture of survival analysis models — cluster-weighted Weibull distributions. *IEEE Access* 9 (2021) 152288–152299. [doi:10.1109/ACCESS.2021.3127576](https://doi.org/10.1109/ACCESS.2021.3127576)
93
+ * R. Csalódi, Z. Birkner, J. Abonyi: Learning interpretable mixture of Weibull distributions. *Data* 6 (2021) 125. [doi:10.3390/data6120125](https://doi.org/10.3390/data6120125)
94
+ * R. Csalódi, J. Abonyi: Integrated survival analysis and frequent pattern mining for course failure-based prediction of student dropout. *Mathematics* 9 (2021) 463. [doi:10.3390/math9050463](https://doi.org/10.3390/math9050463)
95
+ * R. Csalódi, Z. Bagyura, Á. Vathy-Fogarassy, J. Abonyi: Time-dependent frequent sequence mining-based survival analysis. *Knowledge-Based Systems* (2024) 111885. [doi:10.1016/j.knosys.2024.111885](https://doi.org/10.1016/j.knosys.2024.111885)
96
+ * R. Csalódi, Z. Bagyura, J. Abonyi: Time-dependent sequential association rule-based survival analysis: a healthcare application. *MethodsX* (2024) 102535. [doi:10.1016/j.mex.2023.102535](https://doi.org/10.1016/j.mex.2023.102535)
97
+ * T. Ruppert, R. Csalódi, J. Abonyi: Estimation of machine setup and changeover times by survival analysis. *Computers & Industrial Engineering* 153 (2021) 107026. [doi:10.1016/j.cie.2020.107026](https://doi.org/10.1016/j.cie.2020.107026)
98
+ * R. Csalódi: *Machine learning supported survival analysis*. PhD thesis, University of Pannonia (2024). [doi:10.18136/PE.2024.893](https://doi.org/10.18136/PE.2024.893)
99
+
100
+ ## License
101
+
102
+ Code: MIT. Book (`book/`): CC BY 4.0. The research was supported by the
103
+ National Research, Development and Innovation Office of Hungary (NKFIH)
104
+ through the OTKA 143482 project.
@@ -0,0 +1,82 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.25"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "survml"
7
+ dynamic = ["version"]
8
+ description = "Integrated survival analysis and machine learning: cluster-weighted Weibull mixtures with fuzzy rules, itemset- and sequence-based time-dependent rules for competing risks, Fine-Gray regression, pseudo-observations, RMST, mixture cure models, survival stacking and conformal lower prediction bounds."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.10"
13
+ authors = [
14
+ { name = "Róbert Csalódi" },
15
+ { name = "János Abonyi", email = "janos@abonyilab.com" },
16
+ ]
17
+ maintainers = [
18
+ { name = "János Abonyi", email = "janos@abonyilab.com" },
19
+ ]
20
+ keywords = ["survival analysis", "time-to-event", "competing risks", "Weibull mixture", "expectation maximization",
21
+ "fuzzy rules", "frequent itemsets", "sequential pattern mining", "sequential rules", "Fine-Gray",
22
+ "pseudo-observations", "restricted mean survival time", "cure model", "survival stacking",
23
+ "conformal prediction", "process mining"]
24
+ classifiers = [
25
+ "Development Status :: 5 - Production/Stable",
26
+ "Intended Audience :: Science/Research",
27
+ "License :: OSI Approved :: MIT License",
28
+ "Programming Language :: Python :: 3",
29
+ "Programming Language :: Python :: 3.10",
30
+ "Programming Language :: Python :: 3.11",
31
+ "Programming Language :: Python :: 3.12",
32
+ "Programming Language :: Python :: 3.13",
33
+ "Topic :: Scientific/Engineering",
34
+ "Topic :: Scientific/Engineering :: Information Analysis",
35
+ "Topic :: Scientific/Engineering :: Mathematics",
36
+ "Topic :: Scientific/Engineering :: Medical Science Apps.",
37
+ "Operating System :: OS Independent",
38
+ ]
39
+ dependencies = [
40
+ "numpy>=1.24",
41
+ "scipy>=1.11",
42
+ "pandas>=2.0",
43
+ "matplotlib>=3.7",
44
+ "scikit-learn>=1.3",
45
+ "lifelines>=0.27",
46
+ ]
47
+
48
+ [project.optional-dependencies]
49
+ docs = [
50
+ "sphinx>=7", "pydata-sphinx-theme", "sphinx-gallery>=0.15", "numpydoc",
51
+ "myst-parser", "sphinx-copybutton", "sphinx-design",
52
+ ]
53
+ test = ["pytest>=7", "pytest-cov", "scikit-survival>=0.22"]
54
+ dev = ["survml[docs,test]", "ruff", "build", "twine"]
55
+
56
+ [project.urls]
57
+ Homepage = "https://github.com/ComplexSystemsIntelligence/survml"
58
+ Documentation = "https://complexsystemsintelligence.github.io/survml"
59
+ Repository = "https://github.com/ComplexSystemsIntelligence/survml"
60
+ Issues = "https://github.com/ComplexSystemsIntelligence/survml/issues"
61
+
62
+ [tool.hatch.version]
63
+ path = "src/survml/_version.py"
64
+
65
+ [tool.hatch.build.targets.wheel]
66
+ packages = ["src/survml"]
67
+
68
+ [tool.hatch.build.targets.sdist]
69
+ include = ["src/survml", "tests", "README.md", "LICENSE", "CHANGELOG.md", "CITATION.cff", "pyproject.toml"]
70
+
71
+ [tool.pytest.ini_options]
72
+ testpaths = ["tests"]
73
+ pythonpath = ["tests"]
74
+ filterwarnings = ["ignore::DeprecationWarning", "ignore::FutureWarning"]
75
+
76
+ [tool.ruff]
77
+ line-length = 120
78
+ target-version = "py310"
79
+
80
+ [tool.ruff.lint]
81
+ select = ["E", "F", "W", "I", "B", "UP"]
82
+ ignore = ["E741", "B007", "B905", "E731", "UP006", "UP035", "B008", "B023", "E501"]
@@ -0,0 +1,74 @@
1
+ """survml — integrated survival analysis and machine learning in Python.
2
+
3
+ The package implements the integrated algorithms of Csalódi and Abonyi and
4
+ recent survival methods that have no Python implementation elsewhere, on top
5
+ of a small set of classical estimators:
6
+
7
+ * classical building blocks with weights: Kaplan–Meier, Nelson–Aalen,
8
+ Aalen–Johansen, weighted log-rank tests (:mod:`survml.core`);
9
+ * cluster-weighted mixtures of local Weibull (and other) survival models with
10
+ Gaussian and categorical gates, fitted by EM, read as Takagi–Sugeno fuzzy
11
+ rules (:mod:`survml.mixture`, :mod:`survml.distributions`);
12
+ * frequent itemset-based association rules and cumulative incidence functions
13
+ of competing risks (:mod:`survml.itemsets`);
14
+ * time-dependent confidences of frequent sequences and sequential rules, with
15
+ bootstrap bands and a censoring-aware estimator (:mod:`survml.sequences`,
16
+ :mod:`survml.patterns`);
17
+ * root causes of long durations by Cox regression (:mod:`survml.changeover`);
18
+ * Fine–Gray competing-risks regression (:mod:`survml.competing`),
19
+ pseudo-observation regression (:mod:`survml.pseudo`), restricted mean
20
+ survival and time lost (:mod:`survml.restricted`), mixture cure models
21
+ (:mod:`survml.cure`), survival stacking (:mod:`survml.stacking`),
22
+ conformal lower prediction bounds with fixed and adaptive cut-offs
23
+ (:mod:`survml.conformal`);
24
+ * metrics (:mod:`survml.metrics`), public data sets (:mod:`survml.datasets`),
25
+ simulators with known truth (:mod:`survml.simulate`) and plots (:mod:`survml.viz`).
26
+ """
27
+
28
+ from . import (
29
+ changeover,
30
+ competing,
31
+ conformal,
32
+ core,
33
+ cure,
34
+ datasets,
35
+ distributions,
36
+ itemsets,
37
+ metrics,
38
+ mixture,
39
+ patterns,
40
+ pseudo,
41
+ restricted,
42
+ sequences,
43
+ simulate,
44
+ stacking,
45
+ viz,
46
+ )
47
+ from ._version import __version__
48
+ from .changeover import DurationRootCause
49
+ from .competing import FineGray
50
+ from .conformal import CensoringModel, ConformalSurvival
51
+ from .core import AalenJohansen, KaplanMeier, NelsonAalen, bootstrap_band, logrank_test, pairwise_logrank
52
+ from .cure import MixtureCure
53
+ from .itemsets import PeriodItemsetSurvival, discrete_cif
54
+ from .metrics import brier_score, concordance_index, d_calibration, integrated_brier_score, uno_concordance
55
+ from .mixture import ClusterWeightedSurvival, select_n_components
56
+ from .patterns import build_traces, frequent_itemsets, frequent_sequences, sequential_rules
57
+ from .pseudo import PseudoRegression, pseudo_observations
58
+ from .restricted import rmst, rmst_test, rmtl
59
+ from .sequences import FrequentSequenceSurvival, SequentialRuleSurvival
60
+ from .stacking import SurvivalStacking
61
+
62
+ __all__ = [
63
+ "__version__",
64
+ "KaplanMeier", "NelsonAalen", "AalenJohansen", "logrank_test", "pairwise_logrank", "bootstrap_band",
65
+ "ClusterWeightedSurvival", "select_n_components",
66
+ "PeriodItemsetSurvival", "discrete_cif",
67
+ "FrequentSequenceSurvival", "SequentialRuleSurvival",
68
+ "frequent_itemsets", "frequent_sequences", "sequential_rules", "build_traces",
69
+ "DurationRootCause", "FineGray", "PseudoRegression", "pseudo_observations",
70
+ "rmst", "rmst_test", "rmtl", "MixtureCure", "SurvivalStacking", "ConformalSurvival", "CensoringModel",
71
+ "concordance_index", "uno_concordance", "brier_score", "integrated_brier_score", "d_calibration",
72
+ "changeover", "competing", "conformal", "core", "cure", "datasets", "distributions", "itemsets", "metrics",
73
+ "mixture", "patterns", "pseudo", "restricted", "sequences", "simulate", "stacking", "viz",
74
+ ]