survivalist 0.0.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.
- survivalist-0.0.0/LICENSE +32 -0
- survivalist-0.0.0/MANIFEST.in +19 -0
- survivalist-0.0.0/PKG-INFO +102 -0
- survivalist-0.0.0/README.md +1 -0
- survivalist-0.0.0/pyproject.toml +211 -0
- survivalist-0.0.0/setup.cfg +4 -0
- survivalist-0.0.0/setup.py +140 -0
- survivalist-0.0.0/survivalist/__init__.py +140 -0
- survivalist-0.0.0/survivalist/base.py +132 -0
- survivalist-0.0.0/survivalist/column.py +213 -0
- survivalist-0.0.0/survivalist/compare.py +129 -0
- survivalist-0.0.0/survivalist/custom/__init__.py +2 -0
- survivalist-0.0.0/survivalist/custom/confcustom.py +94 -0
- survivalist-0.0.0/survivalist/custom/custom.py +75 -0
- survivalist-0.0.0/survivalist/datasets/__init__.py +10 -0
- survivalist-0.0.0/survivalist/datasets/base.py +688 -0
- survivalist-0.0.0/survivalist/datasets/data/GBSG2.arff +700 -0
- survivalist-0.0.0/survivalist/datasets/data/actg320.arff +1169 -0
- survivalist-0.0.0/survivalist/datasets/data/breast_cancer_GSE7390-metastasis.arff +283 -0
- survivalist-0.0.0/survivalist/datasets/data/flchain.arff +7887 -0
- survivalist-0.0.0/survivalist/datasets/data/veteran.arff +148 -0
- survivalist-0.0.0/survivalist/datasets/data/whas500.arff +520 -0
- survivalist-0.0.0/survivalist/ensemble/__init__.py +6 -0
- survivalist-0.0.0/survivalist/ensemble/_coxph_loss.pyx +73 -0
- survivalist-0.0.0/survivalist/ensemble/boosting.py +1724 -0
- survivalist-0.0.0/survivalist/ensemble/confgenboosting.py +395 -0
- survivalist-0.0.0/survivalist/ensemble/forest.py +978 -0
- survivalist-0.0.0/survivalist/ensemble/genboosting.py +762 -0
- survivalist-0.0.0/survivalist/ensemble/survival_loss.py +223 -0
- survivalist-0.0.0/survivalist/exceptions.py +18 -0
- survivalist-0.0.0/survivalist/functions.py +121 -0
- survivalist-0.0.0/survivalist/io/__init__.py +2 -0
- survivalist-0.0.0/survivalist/io/arffread.py +60 -0
- survivalist-0.0.0/survivalist/io/arffwrite.py +153 -0
- survivalist-0.0.0/survivalist/linear_model/__init__.py +0 -0
- survivalist-0.0.0/survivalist/linear_model/coxph.py +653 -0
- survivalist-0.0.0/survivalist/meta/__init__.py +13 -0
- survivalist-0.0.0/survivalist/meta/base.py +47 -0
- survivalist-0.0.0/survivalist/meta/ensemble_selection.py +707 -0
- survivalist-0.0.0/survivalist/meta/stacking.py +360 -0
- survivalist-0.0.0/survivalist/metrics.py +1058 -0
- survivalist-0.0.0/survivalist/nonparametric.py +625 -0
- survivalist-0.0.0/survivalist/preprocessing.py +163 -0
- survivalist-0.0.0/survivalist/testing.py +120 -0
- survivalist-0.0.0/survivalist/util.py +364 -0
- survivalist-0.0.0/survivalist/utils/__init__.py +3 -0
- survivalist-0.0.0/survivalist/utils/simulation.py +125 -0
- survivalist-0.0.0/survivalist.egg-info/PKG-INFO +102 -0
- survivalist-0.0.0/survivalist.egg-info/SOURCES.txt +75 -0
- survivalist-0.0.0/survivalist.egg-info/dependency_links.txt +1 -0
- survivalist-0.0.0/survivalist.egg-info/requires.txt +41 -0
- survivalist-0.0.0/survivalist.egg-info/top_level.txt +1 -0
- survivalist-0.0.0/tests/test_aft.py +73 -0
- survivalist-0.0.0/tests/test_binarytrees.py +62 -0
- survivalist-0.0.0/tests/test_boosting.py +900 -0
- survivalist-0.0.0/tests/test_clinical_kernel.py +330 -0
- survivalist-0.0.0/tests/test_column.py +311 -0
- survivalist-0.0.0/tests/test_common.py +12 -0
- survivalist-0.0.0/tests/test_compare.py +460 -0
- survivalist-0.0.0/tests/test_coxnet.py +2173 -0
- survivalist-0.0.0/tests/test_coxph.py +1135 -0
- survivalist-0.0.0/tests/test_datasets.py +557 -0
- survivalist-0.0.0/tests/test_ensemble_selection.py +347 -0
- survivalist-0.0.0/tests/test_forest.py +427 -0
- survivalist-0.0.0/tests/test_functions.py +158 -0
- survivalist-0.0.0/tests/test_io.py +150 -0
- survivalist-0.0.0/tests/test_metrics.py +1207 -0
- survivalist-0.0.0/tests/test_minlip.py +434 -0
- survivalist-0.0.0/tests/test_nonparametric.py +6233 -0
- survivalist-0.0.0/tests/test_pandas_inputs.py +40 -0
- survivalist-0.0.0/tests/test_preprocessing.py +145 -0
- survivalist-0.0.0/tests/test_show_versions.py +19 -0
- survivalist-0.0.0/tests/test_stacking.py +322 -0
- survivalist-0.0.0/tests/test_survival_function.py +43 -0
- survivalist-0.0.0/tests/test_survival_svm.py +919 -0
- survivalist-0.0.0/tests/test_tree.py +855 -0
- survivalist-0.0.0/tests/test_util.py +405 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
The Clear BSD License
|
|
2
|
+
|
|
3
|
+
Copyright (c) [2019-2024] [Thierry Moudiki]
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted (subject to the limitations in the disclaimer
|
|
8
|
+
below) provided that the following conditions are met:
|
|
9
|
+
|
|
10
|
+
* Redistributions of source code must retain the above copyright notice,
|
|
11
|
+
this list of conditions and the following disclaimer.
|
|
12
|
+
|
|
13
|
+
* Redistributions in binary form must reproduce the above copyright
|
|
14
|
+
notice, this list of conditions and the following disclaimer in the
|
|
15
|
+
documentation and/or other materials provided with the distribution.
|
|
16
|
+
|
|
17
|
+
* Neither the name of the copyright holder nor the names of its
|
|
18
|
+
contributors may be used to endorse or promote products derived from this
|
|
19
|
+
software without specific prior written permission.
|
|
20
|
+
|
|
21
|
+
NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY
|
|
22
|
+
THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
23
|
+
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
24
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
|
25
|
+
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
26
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
27
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
28
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
29
|
+
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
|
30
|
+
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
31
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
32
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# by default, the source distribution includes everything that is under version control
|
|
2
|
+
|
|
3
|
+
prune doc/_build
|
|
4
|
+
prune doc/api/generated
|
|
5
|
+
prune .binder
|
|
6
|
+
prune .github
|
|
7
|
+
prune ci
|
|
8
|
+
exclude appveyor.yml .codecov.yml .pre-commit-config.yaml .readthedocs.yaml .zenodo.json
|
|
9
|
+
|
|
10
|
+
global-exclude __pycache__
|
|
11
|
+
global-exclude .ipynb_checkpoints
|
|
12
|
+
global-exclude .git*
|
|
13
|
+
# Cython generated files
|
|
14
|
+
global-exclude _*.c
|
|
15
|
+
global-exclude _*.cpp
|
|
16
|
+
global-exclude *.py[oc]
|
|
17
|
+
global-exclude *.bak
|
|
18
|
+
global-exclude *.swp
|
|
19
|
+
global-exclude *~
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: survivalist
|
|
3
|
+
Version: 0.0.0
|
|
4
|
+
Summary: Survival analysis built on top of scikit-learn
|
|
5
|
+
Author-email: "T. Moudiki" <thierry.moudiki@gmail.com>
|
|
6
|
+
License: The Clear BSD License
|
|
7
|
+
|
|
8
|
+
Copyright (c) [2019-2024] [Thierry Moudiki]
|
|
9
|
+
All rights reserved.
|
|
10
|
+
|
|
11
|
+
Redistribution and use in source and binary forms, with or without
|
|
12
|
+
modification, are permitted (subject to the limitations in the disclaimer
|
|
13
|
+
below) provided that the following conditions are met:
|
|
14
|
+
|
|
15
|
+
* Redistributions of source code must retain the above copyright notice,
|
|
16
|
+
this list of conditions and the following disclaimer.
|
|
17
|
+
|
|
18
|
+
* Redistributions in binary form must reproduce the above copyright
|
|
19
|
+
notice, this list of conditions and the following disclaimer in the
|
|
20
|
+
documentation and/or other materials provided with the distribution.
|
|
21
|
+
|
|
22
|
+
* Neither the name of the copyright holder nor the names of its
|
|
23
|
+
contributors may be used to endorse or promote products derived from this
|
|
24
|
+
software without specific prior written permission.
|
|
25
|
+
|
|
26
|
+
NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY
|
|
27
|
+
THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
28
|
+
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
29
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
|
30
|
+
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
31
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
32
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
33
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
34
|
+
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
|
|
35
|
+
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
36
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
37
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
38
|
+
Project-URL: Homepage, https://techtonique.github.io/survivalist
|
|
39
|
+
Project-URL: Documentation, https://techtonique.github.io/survivalist
|
|
40
|
+
Project-URL: Source Code, https://github.com/Techtonique/survivalist
|
|
41
|
+
Project-URL: Bug Tracker, https://github.com/Techtonique/survivalist/issues
|
|
42
|
+
Project-URL: Release Notes, https://github.com/Techtonique/survivalist/releases
|
|
43
|
+
Classifier: Development Status :: 4 - Beta
|
|
44
|
+
Classifier: Intended Audience :: Science/Research
|
|
45
|
+
Classifier: Intended Audience :: Developers
|
|
46
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
47
|
+
Classifier: Operating System :: MacOS
|
|
48
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
49
|
+
Classifier: Operating System :: POSIX
|
|
50
|
+
Classifier: Programming Language :: C++
|
|
51
|
+
Classifier: Programming Language :: Cython
|
|
52
|
+
Classifier: Programming Language :: Python
|
|
53
|
+
Classifier: Programming Language :: Python :: 3
|
|
54
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
55
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
56
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
57
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
58
|
+
Classifier: Topic :: Software Development
|
|
59
|
+
Classifier: Topic :: Scientific/Engineering
|
|
60
|
+
Requires-Python: >=3.10
|
|
61
|
+
Description-Content-Type: text/markdown
|
|
62
|
+
License-File: LICENSE
|
|
63
|
+
Requires-Dist: ecos
|
|
64
|
+
Requires-Dist: joblib
|
|
65
|
+
Requires-Dist: numexpr
|
|
66
|
+
Requires-Dist: numpy
|
|
67
|
+
Requires-Dist: osqp!=0.6.0,!=0.6.1
|
|
68
|
+
Requires-Dist: pandas>=1.4.0
|
|
69
|
+
Requires-Dist: scipy>=1.3.2
|
|
70
|
+
Requires-Dist: scikit-learn<1.6,>=1.4.0
|
|
71
|
+
Requires-Dist: nnetsauce
|
|
72
|
+
Provides-Extra: dev
|
|
73
|
+
Requires-Dist: black[jupyter]; extra == "dev"
|
|
74
|
+
Requires-Dist: build; extra == "dev"
|
|
75
|
+
Requires-Dist: coverage; extra == "dev"
|
|
76
|
+
Requires-Dist: Cython>=3.0.10; extra == "dev"
|
|
77
|
+
Requires-Dist: packaging; extra == "dev"
|
|
78
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
79
|
+
Requires-Dist: pytest; extra == "dev"
|
|
80
|
+
Requires-Dist: ruff; extra == "dev"
|
|
81
|
+
Requires-Dist: setuptools-scm>=8; extra == "dev"
|
|
82
|
+
Requires-Dist: tomli; extra == "dev"
|
|
83
|
+
Requires-Dist: tox; extra == "dev"
|
|
84
|
+
Provides-Extra: docs
|
|
85
|
+
Requires-Dist: ipython!=8.7.0; extra == "docs"
|
|
86
|
+
Requires-Dist: nbsphinx>=0.9.2; extra == "docs"
|
|
87
|
+
Requires-Dist: docutils; extra == "docs"
|
|
88
|
+
Requires-Dist: setuptools-scm; extra == "docs"
|
|
89
|
+
Requires-Dist: sphinx~=7.3.7; extra == "docs"
|
|
90
|
+
Requires-Dist: pydata-sphinx-theme~=0.15.2; extra == "docs"
|
|
91
|
+
Requires-Dist: sphinxcontrib-spelling; extra == "docs"
|
|
92
|
+
Requires-Dist: sphinx-design~=0.5.0; extra == "docs"
|
|
93
|
+
Requires-Dist: sphinx-copybutton~=0.5.2; extra == "docs"
|
|
94
|
+
Provides-Extra: nbval
|
|
95
|
+
Requires-Dist: ipykernel; extra == "nbval"
|
|
96
|
+
Requires-Dist: ipython!=8.7.0; extra == "nbval"
|
|
97
|
+
Requires-Dist: matplotlib~=3.9.0; extra == "nbval"
|
|
98
|
+
Requires-Dist: nbformat; extra == "nbval"
|
|
99
|
+
Requires-Dist: nbval>=0.10.0; extra == "nbval"
|
|
100
|
+
Requires-Dist: seaborn~=0.13.2; extra == "nbval"
|
|
101
|
+
|
|
102
|
+
# survivalist
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# survivalist
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = [
|
|
3
|
+
"setuptools>=64",
|
|
4
|
+
"setuptools-scm>=8",
|
|
5
|
+
"packaging",
|
|
6
|
+
# same as scikit-learn
|
|
7
|
+
"Cython>=3.0.10",
|
|
8
|
+
# building against numpy 2.x is compatible with numpy 1.x
|
|
9
|
+
"numpy>=2.0.0",
|
|
10
|
+
|
|
11
|
+
# scikit-learn requirements
|
|
12
|
+
"scikit-learn~=1.4.0; python_version<='3.12'",
|
|
13
|
+
"scikit-learn~=1.5.0; python_version=='3.13'",
|
|
14
|
+
"scikit-learn; python_version>'3.13'",
|
|
15
|
+
]
|
|
16
|
+
build-backend = "setuptools.build_meta"
|
|
17
|
+
|
|
18
|
+
[project]
|
|
19
|
+
name = "survivalist"
|
|
20
|
+
description = "Survival analysis built on top of scikit-learn"
|
|
21
|
+
readme = "README.md"
|
|
22
|
+
authors = [
|
|
23
|
+
{name = "T. Moudiki", email = "thierry.moudiki@gmail.com"}
|
|
24
|
+
]
|
|
25
|
+
license = {file = "LICENSE"}
|
|
26
|
+
requires-python = ">=3.10"
|
|
27
|
+
classifiers = [
|
|
28
|
+
"Development Status :: 4 - Beta",
|
|
29
|
+
"Intended Audience :: Science/Research",
|
|
30
|
+
"Intended Audience :: Developers",
|
|
31
|
+
"License :: OSI Approved :: BSD License",
|
|
32
|
+
"Operating System :: MacOS",
|
|
33
|
+
"Operating System :: Microsoft :: Windows",
|
|
34
|
+
"Operating System :: POSIX",
|
|
35
|
+
"Programming Language :: C++",
|
|
36
|
+
"Programming Language :: Cython",
|
|
37
|
+
"Programming Language :: Python",
|
|
38
|
+
"Programming Language :: Python :: 3",
|
|
39
|
+
"Programming Language :: Python :: 3.10",
|
|
40
|
+
"Programming Language :: Python :: 3.11",
|
|
41
|
+
"Programming Language :: Python :: 3.12",
|
|
42
|
+
"Programming Language :: Python :: 3.13",
|
|
43
|
+
"Topic :: Software Development",
|
|
44
|
+
"Topic :: Scientific/Engineering"
|
|
45
|
+
]
|
|
46
|
+
dependencies = [
|
|
47
|
+
"ecos",
|
|
48
|
+
"joblib",
|
|
49
|
+
"numexpr",
|
|
50
|
+
"numpy",
|
|
51
|
+
"osqp !=0.6.0,!=0.6.1",
|
|
52
|
+
"pandas >=1.4.0",
|
|
53
|
+
"scipy >=1.3.2",
|
|
54
|
+
"scikit-learn >=1.4.0,<1.6",
|
|
55
|
+
"nnetsauce"
|
|
56
|
+
]
|
|
57
|
+
dynamic = ["version"]
|
|
58
|
+
|
|
59
|
+
[project.urls]
|
|
60
|
+
"Homepage" = "https://techtonique.github.io/survivalist"
|
|
61
|
+
"Documentation" = "https://techtonique.github.io/survivalist"
|
|
62
|
+
"Source Code" = "https://github.com/Techtonique/survivalist"
|
|
63
|
+
"Bug Tracker" = "https://github.com/Techtonique/survivalist/issues"
|
|
64
|
+
"Release Notes" = "https://github.com/Techtonique/survivalist/releases"
|
|
65
|
+
|
|
66
|
+
[project.optional-dependencies]
|
|
67
|
+
dev = [
|
|
68
|
+
"black[jupyter]",
|
|
69
|
+
"build",
|
|
70
|
+
"coverage",
|
|
71
|
+
"Cython >=3.0.10",
|
|
72
|
+
"packaging",
|
|
73
|
+
"pre-commit",
|
|
74
|
+
"pytest",
|
|
75
|
+
"ruff",
|
|
76
|
+
"setuptools-scm >=8",
|
|
77
|
+
"tomli",
|
|
78
|
+
"tox",
|
|
79
|
+
]
|
|
80
|
+
|
|
81
|
+
# This file purposely does not contain libraries that depend on C modules.
|
|
82
|
+
# See https://docs.readthedocs.io/en/latest/faq.html#i-get-import-errors-on-libraries-that-depend-on-c-modules
|
|
83
|
+
docs = [
|
|
84
|
+
"ipython !=8.7.0",
|
|
85
|
+
"nbsphinx>=0.9.2",
|
|
86
|
+
"docutils",
|
|
87
|
+
"setuptools-scm",
|
|
88
|
+
"sphinx ~=7.3.7",
|
|
89
|
+
"pydata-sphinx-theme ~=0.15.2",
|
|
90
|
+
"sphinxcontrib-spelling",
|
|
91
|
+
"sphinx-design ~=0.5.0",
|
|
92
|
+
"sphinx-copybutton ~=0.5.2",
|
|
93
|
+
]
|
|
94
|
+
|
|
95
|
+
nbval = [
|
|
96
|
+
"ipykernel",
|
|
97
|
+
"ipython!=8.7.0",
|
|
98
|
+
"matplotlib~=3.9.0",
|
|
99
|
+
"nbformat",
|
|
100
|
+
"nbval>=0.10.0",
|
|
101
|
+
"seaborn~=0.13.2",
|
|
102
|
+
]
|
|
103
|
+
|
|
104
|
+
[tool.setuptools]
|
|
105
|
+
include-package-data = false
|
|
106
|
+
|
|
107
|
+
[tool.setuptools.packages.find]
|
|
108
|
+
include = ["survivalist*"]
|
|
109
|
+
namespaces = false
|
|
110
|
+
|
|
111
|
+
[tool.setuptools.package-data]
|
|
112
|
+
"survivalist.datasets" = ["data/*.arff"]
|
|
113
|
+
|
|
114
|
+
[tool.black]
|
|
115
|
+
line-length = 120
|
|
116
|
+
target-version = ["py310"]
|
|
117
|
+
|
|
118
|
+
[tool.pytest.ini_options]
|
|
119
|
+
minversion = "6.0"
|
|
120
|
+
addopts = "--strict-markers"
|
|
121
|
+
testpaths = ["tests"]
|
|
122
|
+
filterwarnings = [
|
|
123
|
+
# Treat all warnings as errors other than the ignored ones
|
|
124
|
+
"error",
|
|
125
|
+
# distutils is deprecated in 3.10, scheduled for removal in 3.12
|
|
126
|
+
"ignore:The distutils package is deprecated:DeprecationWarning",
|
|
127
|
+
"ignore:Setuptools is replacing distutils",
|
|
128
|
+
"ignore:distutils Version classes are deprecated.*:DeprecationWarning",
|
|
129
|
+
"ignore:Jupyter is migrating its paths to use standard platformdirs:DeprecationWarning",
|
|
130
|
+
# added with pandas 2.1
|
|
131
|
+
"ignore:DataFrame.applymap has been deprecated:FutureWarning",
|
|
132
|
+
# deprecated since Pandas 2.2.0
|
|
133
|
+
"ignore:\\nPyarrow will become a required dependency of pandas in the next major release of pandas.*:DeprecationWarning",
|
|
134
|
+
# deprecated since Python 3.12
|
|
135
|
+
"ignore:datetime\\.datetime\\.utcfromtimestamp\\(\\) is deprecated and scheduled for removal in a future version.*:DeprecationWarning",
|
|
136
|
+
"ignore:ast\\.Num is deprecated and will be removed in Python 3\\.14.*:DeprecationWarning",
|
|
137
|
+
"ignore:Attribute n is deprecated and will be removed in Python 3\\.14.*:DeprecationWarning",
|
|
138
|
+
# deprecated since NumPy 1.25
|
|
139
|
+
"ignore:np\\.find_common_type is deprecated. Please use `np\\.result_type` or `np\\.promote_types`:DeprecationWarning",
|
|
140
|
+
# deprecated since NumPy 2.0
|
|
141
|
+
"ignore:`trapz` is deprecated\\. Use `trapezoid` instead.*:DeprecationWarning",
|
|
142
|
+
# deprecated since scikit-learn 1.5
|
|
143
|
+
"ignore:'multi_class' was deprecated in version 1\\.5 and will be removed in 1\\.7.*:FutureWarning",
|
|
144
|
+
]
|
|
145
|
+
|
|
146
|
+
[tool.coverage.run]
|
|
147
|
+
branch = true
|
|
148
|
+
plugins = ["Cython.Coverage"]
|
|
149
|
+
relative_files = true
|
|
150
|
+
source = ["survivalist"]
|
|
151
|
+
|
|
152
|
+
[tool.coverage.report]
|
|
153
|
+
exclude_lines = [
|
|
154
|
+
# Have to re-enable the standard pragma
|
|
155
|
+
"pragma: no cover",
|
|
156
|
+
|
|
157
|
+
# Don't complain about missing debug-only code:
|
|
158
|
+
"def __repr__",
|
|
159
|
+
"if self\\.debug",
|
|
160
|
+
|
|
161
|
+
# Don't complain if tests don't hit defensive assertion code:
|
|
162
|
+
"raise AssertionError",
|
|
163
|
+
"raise NotImplementedError",
|
|
164
|
+
|
|
165
|
+
# Don't complain if non-runnable code isn't run:
|
|
166
|
+
"if 0:",
|
|
167
|
+
"if __name__ == .__main__.:",
|
|
168
|
+
]
|
|
169
|
+
ignore_errors = true
|
|
170
|
+
|
|
171
|
+
omit = [
|
|
172
|
+
"tests/*",
|
|
173
|
+
"*/setup.py",
|
|
174
|
+
"*/_version.py",
|
|
175
|
+
]
|
|
176
|
+
|
|
177
|
+
[tool.ruff]
|
|
178
|
+
extend-exclude = [
|
|
179
|
+
"doc/conf.py",
|
|
180
|
+
]
|
|
181
|
+
# Group violations by containing file.
|
|
182
|
+
output-format = "grouped"
|
|
183
|
+
line-length = 120
|
|
184
|
+
target-version = "py310"
|
|
185
|
+
|
|
186
|
+
[tool.ruff.lint]
|
|
187
|
+
ignore = ["C408"]
|
|
188
|
+
ignore-init-module-imports = true
|
|
189
|
+
select = [
|
|
190
|
+
"C4",
|
|
191
|
+
"C9",
|
|
192
|
+
"E",
|
|
193
|
+
"F",
|
|
194
|
+
"I",
|
|
195
|
+
"PT",
|
|
196
|
+
"W",
|
|
197
|
+
]
|
|
198
|
+
|
|
199
|
+
[tool.ruff.lint.flake8-pytest-style]
|
|
200
|
+
fixture-parentheses = true
|
|
201
|
+
mark-parentheses = true
|
|
202
|
+
parametrize-names-type = "csv"
|
|
203
|
+
|
|
204
|
+
[tool.ruff.lint.mccabe]
|
|
205
|
+
max-complexity = 10
|
|
206
|
+
|
|
207
|
+
[tool.ruff.lint.isort]
|
|
208
|
+
force-sort-within-sections = true
|
|
209
|
+
known-first-party = ["survivalist"]
|
|
210
|
+
|
|
211
|
+
[tool.setuptools_scm]
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import os
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
import shutil
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
from packaging import version
|
|
7
|
+
from setuptools import Command, Extension, setup
|
|
8
|
+
|
|
9
|
+
CYTHON_MIN_VERSION = version.parse("0.29")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
# adapted from bottleneck's setup.py
|
|
13
|
+
class clean(Command):
|
|
14
|
+
user_options = [("all", "a", "")]
|
|
15
|
+
|
|
16
|
+
def initialize_options(self):
|
|
17
|
+
self.all = True
|
|
18
|
+
self.delete_dirs = []
|
|
19
|
+
self.delete_files = []
|
|
20
|
+
|
|
21
|
+
for root, dirs, files in os.walk("survivalist"):
|
|
22
|
+
root = Path(root)
|
|
23
|
+
for d in dirs:
|
|
24
|
+
if d == "__pycache__":
|
|
25
|
+
self.delete_dirs.append(root / d)
|
|
26
|
+
|
|
27
|
+
if "__pycache__" in root.name:
|
|
28
|
+
continue
|
|
29
|
+
|
|
30
|
+
for f in (root / x for x in files):
|
|
31
|
+
ext = f.suffix
|
|
32
|
+
if ext == ".pyc" or ext == ".so":
|
|
33
|
+
self.delete_files.append(f)
|
|
34
|
+
|
|
35
|
+
if ext in (
|
|
36
|
+
".c",
|
|
37
|
+
".cpp",
|
|
38
|
+
):
|
|
39
|
+
source_file = f.with_suffix(".pyx")
|
|
40
|
+
if source_file.exists():
|
|
41
|
+
self.delete_files.append(f)
|
|
42
|
+
|
|
43
|
+
build_path = Path("build")
|
|
44
|
+
if build_path.exists():
|
|
45
|
+
self.delete_dirs.append(build_path)
|
|
46
|
+
|
|
47
|
+
def finalize_options(self):
|
|
48
|
+
pass
|
|
49
|
+
|
|
50
|
+
def run(self):
|
|
51
|
+
for delete_dir in self.delete_dirs:
|
|
52
|
+
shutil.rmtree(delete_dir)
|
|
53
|
+
for delete_file in self.delete_files:
|
|
54
|
+
delete_file.unlink()
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
EXTENSIONS = {
|
|
58
|
+
"_coxph_loss": {"sources": ["survivalist/ensemble/_coxph_loss.pyx"]},
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def get_module_from_sources(sources):
|
|
63
|
+
for src_path in map(Path, sources):
|
|
64
|
+
if src_path.suffix == ".pyx":
|
|
65
|
+
return ".".join(src_path.parts[:-1] + (src_path.stem,))
|
|
66
|
+
raise ValueError(f"could not find module from sources: {sources!r}")
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def _check_cython_version():
|
|
70
|
+
message = (
|
|
71
|
+
f"Please install Cython with a version >= {CYTHON_MIN_VERSION} in order to build a scikit-learn from source."
|
|
72
|
+
)
|
|
73
|
+
try:
|
|
74
|
+
import Cython
|
|
75
|
+
except ModuleNotFoundError:
|
|
76
|
+
# Re-raise with more informative error message instead:
|
|
77
|
+
raise ModuleNotFoundError(message)
|
|
78
|
+
|
|
79
|
+
if version.parse(Cython.__version__) < CYTHON_MIN_VERSION:
|
|
80
|
+
message += f" The current version of Cython is {Cython.__version__} installed in {Cython.__path__}."
|
|
81
|
+
raise ValueError(message)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def cythonize_extensions(extensions):
|
|
85
|
+
"""Check that a recent Cython is available and cythonize extensions"""
|
|
86
|
+
_check_cython_version()
|
|
87
|
+
from Cython.Build import cythonize
|
|
88
|
+
|
|
89
|
+
# http://docs.cython.org/en/latest/src/userguide/source_files_and_compilation.html#cythonize-arguments
|
|
90
|
+
directives = {"language_level": "3"}
|
|
91
|
+
cy_cov = os.environ.get("CYTHON_COVERAGE", False)
|
|
92
|
+
macros = [("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION")]
|
|
93
|
+
if cy_cov:
|
|
94
|
+
directives["linetrace"] = True
|
|
95
|
+
macros.append(("CYTHON_TRACE", "1"))
|
|
96
|
+
macros.append(("CYTHON_TRACE_NOGIL", "1"))
|
|
97
|
+
|
|
98
|
+
for ext in extensions:
|
|
99
|
+
if ext.define_macros is None:
|
|
100
|
+
ext.define_macros = macros
|
|
101
|
+
else:
|
|
102
|
+
ext.define_macros += macros
|
|
103
|
+
|
|
104
|
+
return cythonize(extensions, compiler_directives=directives)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def get_extensions():
|
|
108
|
+
import numpy
|
|
109
|
+
|
|
110
|
+
numpy_includes = [numpy.get_include()]
|
|
111
|
+
|
|
112
|
+
extensions = []
|
|
113
|
+
for config in EXTENSIONS.values():
|
|
114
|
+
name = get_module_from_sources(config["sources"])
|
|
115
|
+
include_dirs = numpy_includes + config.get("include_dirs", [])
|
|
116
|
+
extra_compile_args = config.get("extra_compile_args", [])
|
|
117
|
+
language = config.get("language", "c")
|
|
118
|
+
ext = Extension(
|
|
119
|
+
name=name,
|
|
120
|
+
sources=config["sources"],
|
|
121
|
+
include_dirs=include_dirs,
|
|
122
|
+
extra_compile_args=extra_compile_args,
|
|
123
|
+
language=language,
|
|
124
|
+
)
|
|
125
|
+
extensions.append(ext)
|
|
126
|
+
|
|
127
|
+
# Skip cythonization as we do not want to include the generated
|
|
128
|
+
# C/C++ files in the release tarballs as they are not necessarily
|
|
129
|
+
# forward compatible with future versions of Python for instance.
|
|
130
|
+
if "sdist" not in sys.argv and "clean" not in sys.argv:
|
|
131
|
+
extensions = cythonize_extensions(extensions)
|
|
132
|
+
|
|
133
|
+
return extensions
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
if __name__ == "__main__":
|
|
137
|
+
setup(
|
|
138
|
+
ext_modules=get_extensions(),
|
|
139
|
+
cmdclass={"clean": clean},
|
|
140
|
+
)
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
2
|
+
import platform
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
from sklearn.pipeline import Pipeline, _final_estimator_has
|
|
6
|
+
from sklearn.utils.metaestimators import available_if
|
|
7
|
+
|
|
8
|
+
from .util import property_available_if
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def _get_version(name):
|
|
12
|
+
try:
|
|
13
|
+
pkg_version = version(name)
|
|
14
|
+
except ImportError:
|
|
15
|
+
pkg_version = None
|
|
16
|
+
return pkg_version
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def show_versions():
|
|
20
|
+
sys_info = {
|
|
21
|
+
"Platform": platform.platform(),
|
|
22
|
+
"Python version": f"{platform.python_implementation()} {platform}",
|
|
23
|
+
"Python interpreter": sys.executable,
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
deps = [
|
|
27
|
+
"survivalist",
|
|
28
|
+
"scikit-learn",
|
|
29
|
+
"numpy",
|
|
30
|
+
"scipy",
|
|
31
|
+
"pandas",
|
|
32
|
+
"numexpr",
|
|
33
|
+
"ecos",
|
|
34
|
+
"osqp",
|
|
35
|
+
"joblib",
|
|
36
|
+
"matplotlib",
|
|
37
|
+
"pytest",
|
|
38
|
+
"sphinx",
|
|
39
|
+
"Cython",
|
|
40
|
+
"pip",
|
|
41
|
+
"setuptools",
|
|
42
|
+
]
|
|
43
|
+
minwidth = max(
|
|
44
|
+
max(map(len, deps)),
|
|
45
|
+
max(map(len, sys_info.keys())),
|
|
46
|
+
)
|
|
47
|
+
fmt = "{0:<%ds}: {1}" % minwidth
|
|
48
|
+
|
|
49
|
+
print("SYSTEM")
|
|
50
|
+
print("------")
|
|
51
|
+
for name, version_string in sys_info.items():
|
|
52
|
+
print(fmt.format(name, version_string))
|
|
53
|
+
|
|
54
|
+
print("\nDEPENDENCIES")
|
|
55
|
+
print("------------")
|
|
56
|
+
for dep in deps:
|
|
57
|
+
version_string = _get_version(dep)
|
|
58
|
+
print(fmt.format(dep, version_string))
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@available_if(_final_estimator_has("predict_cumulative_hazard_function"))
|
|
62
|
+
def predict_cumulative_hazard_function(self, X, **kwargs):
|
|
63
|
+
"""Predict cumulative hazard function.
|
|
64
|
+
|
|
65
|
+
The cumulative hazard function for an individual
|
|
66
|
+
with feature vector :math:`x` is defined as
|
|
67
|
+
|
|
68
|
+
.. math::
|
|
69
|
+
|
|
70
|
+
H(t \\mid x) = \\exp(x^\\top \\beta) H_0(t) ,
|
|
71
|
+
|
|
72
|
+
where :math:`H_0(t)` is the baseline hazard function,
|
|
73
|
+
estimated by Breslow's estimator.
|
|
74
|
+
|
|
75
|
+
Parameters
|
|
76
|
+
----------
|
|
77
|
+
X : array-like, shape = (n_samples, n_features)
|
|
78
|
+
Data matrix.
|
|
79
|
+
|
|
80
|
+
Returns
|
|
81
|
+
-------
|
|
82
|
+
cum_hazard : ndarray, shape = (n_samples,)
|
|
83
|
+
Predicted cumulative hazard functions.
|
|
84
|
+
"""
|
|
85
|
+
Xt = X
|
|
86
|
+
for _, _, transform in self._iter(with_final=False):
|
|
87
|
+
Xt = transform.transform(Xt)
|
|
88
|
+
return self.steps[-1][-1].predict_cumulative_hazard_function(Xt, **kwargs)
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
@available_if(_final_estimator_has("predict_survival_function"))
|
|
92
|
+
def predict_survival_function(self, X, **kwargs):
|
|
93
|
+
"""Predict survival function.
|
|
94
|
+
|
|
95
|
+
The survival function for an individual
|
|
96
|
+
with feature vector :math:`x` is defined as
|
|
97
|
+
|
|
98
|
+
.. math::
|
|
99
|
+
|
|
100
|
+
S(t \\mid x) = S_0(t)^{\\exp(x^\\top \\beta)} ,
|
|
101
|
+
|
|
102
|
+
where :math:`S_0(t)` is the baseline survival function,
|
|
103
|
+
estimated by Breslow's estimator.
|
|
104
|
+
|
|
105
|
+
Parameters
|
|
106
|
+
----------
|
|
107
|
+
X : array-like, shape = (n_samples, n_features)
|
|
108
|
+
Data matrix.
|
|
109
|
+
|
|
110
|
+
Returns
|
|
111
|
+
-------
|
|
112
|
+
survival : ndarray, shape = (n_samples,)
|
|
113
|
+
Predicted survival functions.
|
|
114
|
+
"""
|
|
115
|
+
Xt = X
|
|
116
|
+
for _, _, transform in self._iter(with_final=False):
|
|
117
|
+
Xt = transform.transform(Xt)
|
|
118
|
+
return self.steps[-1][-1].predict_survival_function(Xt, **kwargs)
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
@property_available_if(_final_estimator_has("_predict_risk_score"))
|
|
122
|
+
def _predict_risk_score(self):
|
|
123
|
+
return self.steps[-1][-1]._predict_risk_score
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def patch_pipeline():
|
|
127
|
+
Pipeline.predict_survival_function = predict_survival_function
|
|
128
|
+
Pipeline.predict_cumulative_hazard_function = (
|
|
129
|
+
predict_cumulative_hazard_function
|
|
130
|
+
)
|
|
131
|
+
Pipeline._predict_risk_score = _predict_risk_score
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
try:
|
|
135
|
+
__version__ = version("survivalist")
|
|
136
|
+
except PackageNotFoundError: # pragma: no cover
|
|
137
|
+
# package is not installed
|
|
138
|
+
__version__ = "unknown"
|
|
139
|
+
|
|
140
|
+
patch_pipeline()
|