scikit-survival 0.25.0__cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
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.
- scikit_survival-0.25.0.dist-info/METADATA +185 -0
- scikit_survival-0.25.0.dist-info/RECORD +58 -0
- scikit_survival-0.25.0.dist-info/WHEEL +6 -0
- scikit_survival-0.25.0.dist-info/licenses/COPYING +674 -0
- scikit_survival-0.25.0.dist-info/top_level.txt +1 -0
- sksurv/__init__.py +183 -0
- sksurv/base.py +115 -0
- sksurv/bintrees/__init__.py +15 -0
- sksurv/bintrees/_binarytrees.cpython-311-x86_64-linux-gnu.so +0 -0
- sksurv/column.py +205 -0
- sksurv/compare.py +123 -0
- sksurv/datasets/__init__.py +12 -0
- sksurv/datasets/base.py +614 -0
- sksurv/datasets/data/GBSG2.arff +700 -0
- sksurv/datasets/data/actg320.arff +1169 -0
- sksurv/datasets/data/bmt.arff +46 -0
- sksurv/datasets/data/breast_cancer_GSE7390-metastasis.arff +283 -0
- sksurv/datasets/data/cgvhd.arff +118 -0
- sksurv/datasets/data/flchain.arff +7887 -0
- sksurv/datasets/data/veteran.arff +148 -0
- sksurv/datasets/data/whas500.arff +520 -0
- sksurv/docstrings.py +99 -0
- sksurv/ensemble/__init__.py +2 -0
- sksurv/ensemble/_coxph_loss.cpython-311-x86_64-linux-gnu.so +0 -0
- sksurv/ensemble/boosting.py +1564 -0
- sksurv/ensemble/forest.py +902 -0
- sksurv/ensemble/survival_loss.py +151 -0
- sksurv/exceptions.py +18 -0
- sksurv/functions.py +114 -0
- sksurv/io/__init__.py +2 -0
- sksurv/io/arffread.py +89 -0
- sksurv/io/arffwrite.py +181 -0
- sksurv/kernels/__init__.py +1 -0
- sksurv/kernels/_clinical_kernel.cpython-311-x86_64-linux-gnu.so +0 -0
- sksurv/kernels/clinical.py +348 -0
- sksurv/linear_model/__init__.py +3 -0
- sksurv/linear_model/_coxnet.cpython-311-x86_64-linux-gnu.so +0 -0
- sksurv/linear_model/aft.py +208 -0
- sksurv/linear_model/coxnet.py +592 -0
- sksurv/linear_model/coxph.py +637 -0
- sksurv/meta/__init__.py +4 -0
- sksurv/meta/base.py +35 -0
- sksurv/meta/ensemble_selection.py +724 -0
- sksurv/meta/stacking.py +370 -0
- sksurv/metrics.py +1028 -0
- sksurv/nonparametric.py +911 -0
- sksurv/preprocessing.py +183 -0
- sksurv/svm/__init__.py +11 -0
- sksurv/svm/_minlip.cpython-311-x86_64-linux-gnu.so +0 -0
- sksurv/svm/_prsvm.cpython-311-x86_64-linux-gnu.so +0 -0
- sksurv/svm/minlip.py +690 -0
- sksurv/svm/naive_survival_svm.py +249 -0
- sksurv/svm/survival_svm.py +1236 -0
- sksurv/testing.py +108 -0
- sksurv/tree/__init__.py +1 -0
- sksurv/tree/_criterion.cpython-311-x86_64-linux-gnu.so +0 -0
- sksurv/tree/tree.py +790 -0
- sksurv/util.py +415 -0
sksurv/testing.py
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# This program is free software: you can redistribute it and/or modify
|
|
2
|
+
# it under the terms of the GNU General Public License as published by
|
|
3
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
4
|
+
# (at your option) any later version.
|
|
5
|
+
#
|
|
6
|
+
# This program is distributed in the hope that it will be useful,
|
|
7
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
8
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
9
|
+
# GNU General Public License for more details.
|
|
10
|
+
#
|
|
11
|
+
# You should have received a copy of the GNU General Public License
|
|
12
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
13
|
+
from importlib import import_module
|
|
14
|
+
import inspect
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
import pkgutil
|
|
17
|
+
|
|
18
|
+
import numpy as np
|
|
19
|
+
from numpy.testing import assert_almost_equal, assert_array_equal
|
|
20
|
+
import pytest
|
|
21
|
+
from sklearn.base import BaseEstimator, TransformerMixin
|
|
22
|
+
|
|
23
|
+
import sksurv
|
|
24
|
+
from sksurv.metrics import concordance_index_censored
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def assert_cindex_almost_equal(event_indicator, event_time, estimate, expected):
|
|
28
|
+
result = concordance_index_censored(event_indicator, event_time, estimate)
|
|
29
|
+
assert_array_equal(result[1:], expected[1:])
|
|
30
|
+
concordant, discordant, tied_risk = result[1:4]
|
|
31
|
+
cc = (concordant + 0.5 * tied_risk) / (concordant + discordant + tied_risk)
|
|
32
|
+
assert_almost_equal(result[0], cc)
|
|
33
|
+
assert_almost_equal(result[0], expected[0])
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def assert_survival_function_properties(surv_fns):
|
|
37
|
+
if not np.isfinite(surv_fns).all():
|
|
38
|
+
raise AssertionError("survival function contains values that are not finite")
|
|
39
|
+
if np.any(surv_fns < 0.0):
|
|
40
|
+
raise AssertionError("survival function contains negative values")
|
|
41
|
+
if np.any(surv_fns > 1.0):
|
|
42
|
+
raise AssertionError("survival function contains values larger 1")
|
|
43
|
+
|
|
44
|
+
d = np.apply_along_axis(np.diff, 1, surv_fns)
|
|
45
|
+
if np.any(d > 0):
|
|
46
|
+
raise AssertionError("survival functions are not monotonically decreasing")
|
|
47
|
+
|
|
48
|
+
# survival function at first time point
|
|
49
|
+
num_closer_to_zero = np.sum(1.0 - surv_fns[:, 0] >= surv_fns[:, 0])
|
|
50
|
+
if num_closer_to_zero / surv_fns.shape[0] > 0.5:
|
|
51
|
+
raise AssertionError(f"most ({num_closer_to_zero}) probabilities at first time point are closer to 0 than 1")
|
|
52
|
+
|
|
53
|
+
# survival function at last time point
|
|
54
|
+
num_closer_to_one = np.sum(1.0 - surv_fns[:, -1] < surv_fns[:, -1])
|
|
55
|
+
if num_closer_to_one / surv_fns.shape[0] > 0.5:
|
|
56
|
+
raise AssertionError(f"most ({num_closer_to_one}) probabilities at last time point are closer to 1 than 0")
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def assert_chf_properties(chf):
|
|
60
|
+
if not np.isfinite(chf).all():
|
|
61
|
+
raise AssertionError("chf contains values that are not finite")
|
|
62
|
+
if np.any(chf < 0.0):
|
|
63
|
+
raise AssertionError("chf contains negative values")
|
|
64
|
+
|
|
65
|
+
d = np.apply_along_axis(np.diff, 1, chf)
|
|
66
|
+
if np.any(d < 0):
|
|
67
|
+
raise AssertionError("chf are not monotonically increasing")
|
|
68
|
+
|
|
69
|
+
# chf at first time point
|
|
70
|
+
num_closer_to_one = np.sum(1.0 - chf[:, 0] < chf[:, 0])
|
|
71
|
+
if num_closer_to_one / chf.shape[0] > 0.5:
|
|
72
|
+
raise AssertionError(f"most ({num_closer_to_one}) hazard rates at first time point are closer to 1 than 0")
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
def _is_survival_estimator(x):
|
|
76
|
+
return (
|
|
77
|
+
inspect.isclass(x)
|
|
78
|
+
and issubclass(x, BaseEstimator)
|
|
79
|
+
and not issubclass(x, TransformerMixin)
|
|
80
|
+
and x.__module__.startswith("sksurv.")
|
|
81
|
+
and not x.__name__.startswith("_")
|
|
82
|
+
and x.__module__.split(".", 2)[1] not in {"metrics", "nonparametric"}
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def all_survival_estimators():
|
|
87
|
+
root = str(Path(sksurv.__file__).parent)
|
|
88
|
+
all_classes = []
|
|
89
|
+
for _importer, modname, _ispkg in pkgutil.walk_packages(path=[root], prefix="sksurv."):
|
|
90
|
+
# meta-estimators require base estimators
|
|
91
|
+
if modname.startswith("sksurv.meta"):
|
|
92
|
+
continue
|
|
93
|
+
module = import_module(modname)
|
|
94
|
+
for _name, cls in inspect.getmembers(module, _is_survival_estimator):
|
|
95
|
+
if inspect.isabstract(cls):
|
|
96
|
+
continue
|
|
97
|
+
all_classes.append(cls)
|
|
98
|
+
return set(all_classes)
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
class FixtureParameterFactory:
|
|
102
|
+
def get_cases(self):
|
|
103
|
+
cases = []
|
|
104
|
+
for name, func in inspect.getmembers(self):
|
|
105
|
+
if name.startswith("data_"):
|
|
106
|
+
values = func()
|
|
107
|
+
cases.append(pytest.param(*values, id=name))
|
|
108
|
+
return cases
|
sksurv/tree/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .tree import ExtraSurvivalTree, SurvivalTree # noqa: F401
|
|
Binary file
|