scikit-survival 0.24.1__cp310-cp310-macosx_11_0_arm64.whl → 0.25.0__cp310-cp310-macosx_11_0_arm64.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.
Files changed (39) hide show
  1. scikit_survival-0.25.0.dist-info/METADATA +185 -0
  2. scikit_survival-0.25.0.dist-info/RECORD +58 -0
  3. {scikit_survival-0.24.1.dist-info → scikit_survival-0.25.0.dist-info}/WHEEL +1 -1
  4. sksurv/__init__.py +51 -6
  5. sksurv/base.py +12 -2
  6. sksurv/bintrees/_binarytrees.cpython-310-darwin.so +0 -0
  7. sksurv/column.py +33 -29
  8. sksurv/compare.py +22 -22
  9. sksurv/datasets/base.py +45 -20
  10. sksurv/docstrings.py +99 -0
  11. sksurv/ensemble/_coxph_loss.cpython-310-darwin.so +0 -0
  12. sksurv/ensemble/boosting.py +116 -168
  13. sksurv/ensemble/forest.py +94 -151
  14. sksurv/functions.py +29 -29
  15. sksurv/io/arffread.py +34 -3
  16. sksurv/io/arffwrite.py +38 -2
  17. sksurv/kernels/_clinical_kernel.cpython-310-darwin.so +0 -0
  18. sksurv/kernels/clinical.py +33 -13
  19. sksurv/linear_model/_coxnet.cpython-310-darwin.so +0 -0
  20. sksurv/linear_model/aft.py +14 -11
  21. sksurv/linear_model/coxnet.py +138 -89
  22. sksurv/linear_model/coxph.py +102 -83
  23. sksurv/meta/ensemble_selection.py +91 -9
  24. sksurv/meta/stacking.py +47 -26
  25. sksurv/metrics.py +257 -224
  26. sksurv/nonparametric.py +150 -81
  27. sksurv/preprocessing.py +55 -27
  28. sksurv/svm/_minlip.cpython-310-darwin.so +0 -0
  29. sksurv/svm/_prsvm.cpython-310-darwin.so +0 -0
  30. sksurv/svm/minlip.py +160 -79
  31. sksurv/svm/naive_survival_svm.py +63 -34
  32. sksurv/svm/survival_svm.py +103 -103
  33. sksurv/tree/_criterion.cpython-310-darwin.so +0 -0
  34. sksurv/tree/tree.py +170 -84
  35. sksurv/util.py +80 -26
  36. scikit_survival-0.24.1.dist-info/METADATA +0 -889
  37. scikit_survival-0.24.1.dist-info/RECORD +0 -57
  38. {scikit_survival-0.24.1.dist-info → scikit_survival-0.25.0.dist-info}/licenses/COPYING +0 -0
  39. {scikit_survival-0.24.1.dist-info → scikit_survival-0.25.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,185 @@
1
+ Metadata-Version: 2.4
2
+ Name: scikit-survival
3
+ Version: 0.25.0
4
+ Summary: Survival analysis built on top of scikit-learn
5
+ Author-email: Sebastian Pölsterl <sebp@k-d-w.org>
6
+ License-Expression: GPL-3.0-or-later
7
+ Project-URL: Homepage, https://github.com/sebp/scikit-survival
8
+ Project-URL: Documentation, https://scikit-survival.readthedocs.io
9
+ Project-URL: Source Code, https://github.com/sebp/scikit-survival
10
+ Project-URL: Bug Tracker, https://github.com/sebp/scikit-survival/issues
11
+ Project-URL: Release Notes, https://scikit-survival.readthedocs.io/en/latest/release_notes.html
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Operating System :: MacOS
16
+ Classifier: Operating System :: Microsoft :: Windows
17
+ Classifier: Operating System :: POSIX
18
+ Classifier: Programming Language :: C++
19
+ Classifier: Programming Language :: Cython
20
+ Classifier: Programming Language :: Python
21
+ Classifier: Programming Language :: Python :: 3
22
+ Classifier: Programming Language :: Python :: 3.10
23
+ Classifier: Programming Language :: Python :: 3.11
24
+ Classifier: Programming Language :: Python :: 3.12
25
+ Classifier: Programming Language :: Python :: 3.13
26
+ Classifier: Topic :: Software Development
27
+ Classifier: Topic :: Scientific/Engineering
28
+ Requires-Python: >=3.10
29
+ Description-Content-Type: text/x-rst
30
+ License-File: COPYING
31
+ Requires-Dist: ecos
32
+ Requires-Dist: joblib
33
+ Requires-Dist: numexpr
34
+ Requires-Dist: numpy
35
+ Requires-Dist: osqp<1.0.0,>=0.6.3
36
+ Requires-Dist: pandas>=1.4.0
37
+ Requires-Dist: scipy>=1.3.2
38
+ Requires-Dist: scikit-learn<1.8,>=1.6.1
39
+ Dynamic: license-file
40
+
41
+ |License| |Docs| |DOI|
42
+
43
+ |build-tests| |build-windows| |Codecov| |Codacy|
44
+
45
+ ***************
46
+ scikit-survival
47
+ ***************
48
+
49
+ scikit-survival is a Python module for `survival analysis`_
50
+ built on top of `scikit-learn <https://scikit-learn.org/>`_. It allows doing survival analysis
51
+ while utilizing the power of scikit-learn, e.g., for pre-processing or doing cross-validation.
52
+
53
+ =======================
54
+ About Survival Analysis
55
+ =======================
56
+
57
+ The objective in `survival analysis`_ (also referred to as time-to-event or reliability analysis)
58
+ is to establish a connection between covariates and the time of an event.
59
+ What makes survival analysis differ from traditional machine learning is the fact that
60
+ parts of the training data can only be partially observed – they are *censored*.
61
+
62
+ For instance, in a clinical study, patients are often monitored for a particular time period,
63
+ and events occurring in this particular period are recorded.
64
+ If a patient experiences an event, the exact time of the event can
65
+ be recorded – the patient’s record is uncensored. In contrast, right censored records
66
+ refer to patients that remained event-free during the study period and
67
+ it is unknown whether an event has or has not occurred after the study ended.
68
+ Consequently, survival analysis demands for models that take
69
+ this unique characteristic of such a dataset into account.
70
+
71
+ ============
72
+ Requirements
73
+ ============
74
+
75
+ - Python 3.10 or later
76
+ - ecos
77
+ - joblib
78
+ - numexpr
79
+ - numpy
80
+ - osqp
81
+ - pandas 1.4.0 or later
82
+ - scikit-learn 1.6 or 1.7
83
+ - scipy
84
+ - C/C++ compiler
85
+
86
+ ============
87
+ Installation
88
+ ============
89
+
90
+ The easiest way to install scikit-survival is to use
91
+ `conda-forge <https://conda-forge.org/docs/user/introduction/>`_ by running::
92
+
93
+ conda install -c conda-forge scikit-survival
94
+
95
+ Alternatively, you can install scikit-survival `from PyPI <https://scikit-survival.readthedocs.io/en/stable/install.html#pip>`_
96
+ or `from source <https://scikit-survival.readthedocs.io/en/stable/install.html#from-source>`_.
97
+
98
+ ========
99
+ Examples
100
+ ========
101
+
102
+ The `user guide <https://scikit-survival.readthedocs.io/en/stable/user_guide/index.html>`_ provides
103
+ in-depth information on the key concepts of scikit-survival, an overview of available survival models,
104
+ and hands-on examples in the form of `Jupyter notebooks <https://jupyter.org/>`_.
105
+
106
+ ================
107
+ Help and Support
108
+ ================
109
+
110
+ **Documentation**
111
+
112
+ - HTML documentation for the latest release: https://scikit-survival.readthedocs.io/en/stable/
113
+ - HTML documentation for the development version (master branch): https://scikit-survival.readthedocs.io/en/latest/
114
+ - For a list of notable changes, see the `release notes <https://scikit-survival.readthedocs.io/en/stable/release_notes.html>`_.
115
+
116
+ **Bug reports**
117
+
118
+ - If you encountered a problem, please submit a
119
+ `bug report <https://github.com/sebp/scikit-survival/issues/new?template=bug_report.md>`_.
120
+
121
+ **Questions**
122
+
123
+ - If you have a question on how to use scikit-survival, please use `GitHub Discussions <https://github.com/sebp/scikit-survival/discussions>`_.
124
+ - For general theoretical or methodological questions on survival analysis, please use
125
+ `Cross Validated <https://stats.stackexchange.com/questions/tagged/survival>`_.
126
+
127
+ ============
128
+ Contributing
129
+ ============
130
+
131
+ New contributors are always welcome. Please have a look at the
132
+ `contributing guidelines <https://scikit-survival.readthedocs.io/en/latest/contributing.html>`_
133
+ on how to get started and to make sure your code complies with our guidelines.
134
+
135
+ ==========
136
+ References
137
+ ==========
138
+
139
+ Please cite the following paper if you are using **scikit-survival**.
140
+
141
+ S. Pölsterl, "scikit-survival: A Library for Time-to-Event Analysis Built on Top of scikit-learn,"
142
+ Journal of Machine Learning Research, vol. 21, no. 212, pp. 1–6, 2020.
143
+
144
+ .. code::
145
+
146
+ @article{sksurv,
147
+ author = {Sebastian P{\"o}lsterl},
148
+ title = {scikit-survival: A Library for Time-to-Event Analysis Built on Top of scikit-learn},
149
+ journal = {Journal of Machine Learning Research},
150
+ year = {2020},
151
+ volume = {21},
152
+ number = {212},
153
+ pages = {1-6},
154
+ url = {http://jmlr.org/papers/v21/20-729.html}
155
+ }
156
+
157
+ .. |License| image:: https://img.shields.io/badge/license-GPLv3-blue.svg
158
+ :target: COPYING
159
+ :alt: License
160
+
161
+ .. |Codecov| image:: https://codecov.io/gh/sebp/scikit-survival/branch/master/graph/badge.svg
162
+ :target: https://codecov.io/gh/sebp/scikit-survival
163
+ :alt: codecov
164
+
165
+ .. |Codacy| image:: https://api.codacy.com/project/badge/Grade/17242004cdf6422c9a1052bf1ec63104
166
+ :target: https://app.codacy.com/gh/sebp/scikit-survival/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade
167
+ :alt: Codacy Badge
168
+
169
+ .. |Docs| image:: https://readthedocs.org/projects/scikit-survival/badge/?version=latest
170
+ :target: https://scikit-survival.readthedocs.io/en/latest/
171
+ :alt: readthedocs.org
172
+
173
+ .. |DOI| image:: https://zenodo.org/badge/77409504.svg
174
+ :target: https://zenodo.org/badge/latestdoi/77409504
175
+ :alt: Digital Object Identifier (DOI)
176
+
177
+ .. |build-tests| image:: https://github.com/sebp/scikit-survival/actions/workflows/tests-workflow.yaml/badge.svg?branch=master
178
+ :target: https://github.com/sebp/scikit-survival/actions?query=workflow%3Atests+branch%3Amaster
179
+ :alt: GitHub Actions Tests Status
180
+
181
+ .. |build-windows| image:: https://ci.appveyor.com/api/projects/status/github/sebp/scikit-survival?branch=master&svg=true
182
+ :target: https://ci.appveyor.com/project/sebp/scikit-survival
183
+ :alt: Windows Build Status on AppVeyor
184
+
185
+ .. _survival analysis: https://en.wikipedia.org/wiki/Survival_analysis
@@ -0,0 +1,58 @@
1
+ scikit_survival-0.25.0.dist-info/RECORD,,
2
+ scikit_survival-0.25.0.dist-info/WHEEL,sha256=11kMdE9gzbsaQG30fRcsAYxBLEVRsqJo098Y5iL60Xo,136
3
+ scikit_survival-0.25.0.dist-info/top_level.txt,sha256=fPkcFA-XQGbwnD_ZXOvaOWmSd34Qezr26Mn99nYPvAg,7
4
+ scikit_survival-0.25.0.dist-info/METADATA,sha256=gDfqAfi65Ozo4Ak5qArzmaEGnhAVbjoRFBEM8xtI0Ww,7187
5
+ scikit_survival-0.25.0.dist-info/licenses/COPYING,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
6
+ sksurv/functions.py,sha256=e0jVqnEtyHoI7qjn18gHD2oRTCoOOA3i6p90tDgMWKs,3898
7
+ sksurv/metrics.py,sha256=C8vWJEQ1CysbaG4KRnQA7cHOttDZsLGNAaL1DSVgccI,41241
8
+ sksurv/nonparametric.py,sha256=XNATA2vYpspXqzflT8ckR3zuOqRwBI50zMcLwvs5JxY,31715
9
+ sksurv/util.py,sha256=wbLvsOh5Ta3myMRVmlBazCTcMzV8G_nv1VF4Y1twY-I,15745
10
+ sksurv/__init__.py,sha256=eRitrwFtAUadhvZtcasgO443RRMaPTmJHCph3dWkHSg,5153
11
+ sksurv/docstrings.py,sha256=PJTe7sts8j6x3Gck_18buulAr2HIMOF6GnWDtrLQtIw,3301
12
+ sksurv/preprocessing.py,sha256=rCy0BOvniqfN14XAJqYGu0ihmumB3-gY14UUmO2lf38,6508
13
+ sksurv/exceptions.py,sha256=CRun7zrKzcZ9zinni5b2cMaV-pU-pw1UnXpRV2h3z_4,801
14
+ sksurv/testing.py,sha256=2oeCsTzEiVRKDRb3iSJLKn03hBO2IrUq-2U5TfvOYK4,4295
15
+ sksurv/compare.py,sha256=k610CG3y4OnUkuIhR4hnd_kaLUHNi1qsmL4EBYQ8rLc,4440
16
+ sksurv/base.py,sha256=JGjekQGBRQdwS6AlI6uuNowT3KOpgBHCzxJGq6dsgew,4373
17
+ sksurv/column.py,sha256=D52_WjVEvKPuA-pQdYtbh5hJagCrT8Dg8jaiFfJRHnU,6908
18
+ sksurv/tree/tree.py,sha256=uvCcwIGVqx2x39ycIsLtJSKWBhty37uDKr85zQOBR9U,31992
19
+ sksurv/tree/__init__.py,sha256=7RUjPZtGrVYiHY4roDXdEDM7RVBSsbY_CXWmyqZk2ts,64
20
+ sksurv/tree/_criterion.cpython-310-darwin.so,sha256=bW15JJRXehxsz-dg-wSvAv_Hog8h1Ks7iPKABmuiivc,227680
21
+ sksurv/ensemble/boosting.py,sha256=zLsJdjgPuEunYzPy-xlsmdNAI2U97YnX6aWN3ksFIrM,61572
22
+ sksurv/ensemble/_coxph_loss.cpython-310-darwin.so,sha256=NKjpPz6U_s-PNelYemV_HezlJCavWIbDR6_ZGId1nqk,206480
23
+ sksurv/ensemble/__init__.py,sha256=7kZAzxFpJGtgLQfhoOqZUyGUubIs_Kw3RgyUsAd1Fq0,191
24
+ sksurv/ensemble/survival_loss.py,sha256=mhIbuOqz7t-nuygswZD0d0are2R0EQ3d3yHMRdxOKIk,5942
25
+ sksurv/ensemble/forest.py,sha256=zAo-Txbqc5GjnbfI5fJCUfUHG2NFdFS6dDQhADrBnuM,35268
26
+ sksurv/kernels/clinical.py,sha256=uqwjrmo0ZHpqZQ7oWw_xWl4A47ZO19WsYJWe6zRzPrY,11439
27
+ sksurv/kernels/__init__.py,sha256=_aZIFutv7kUTlkHJlP52zBDkpUXnKIlPPf3cikuAmCA,77
28
+ sksurv/kernels/_clinical_kernel.cpython-310-darwin.so,sha256=TfwJC4iaUgPIlAVOCLkYnwf7d6ZxDQNPkiTrQG6dKQM,206856
29
+ sksurv/bintrees/__init__.py,sha256=l6Fe4PAMByrABpGzZ5W8KHieEYG-rh-DADo2QiEMLrU,727
30
+ sksurv/bintrees/_binarytrees.cpython-310-darwin.so,sha256=rb3hP6gPrNb_Jh-pRCRJGtw4zBZgx64fYOOaNMpNw7M,112480
31
+ sksurv/datasets/__init__.py,sha256=EPzJ50wd-cZ6mWuHFPRRRMqgt14WzM32HGxDrlOp9Q4,361
32
+ sksurv/datasets/base.py,sha256=q6xtOdE-y5WvevZsDidwE_imFtWozUQaWKbAhpPbw7Q,25611
33
+ sksurv/datasets/data/cgvhd.arff,sha256=0lxUqY74JaMpC_vWJC4RWJy6vTmQwCg1yrUxjX65VX8,5214
34
+ sksurv/datasets/data/GBSG2.arff,sha256=jBuh302AIWtYaV1rvJ9RKEZkqzcSThAdVt8ImFFkWwQ,26204
35
+ sksurv/datasets/data/actg320.arff,sha256=8GE2kIU8Nvx7m5Ns-uTJW6Rgtk3xmJzBzMEmtynq5FU,45446
36
+ sksurv/datasets/data/bmt.arff,sha256=yRCh87tAlsBQAocliDquyP28lsnQhCTNU0vJatgH6ns,509
37
+ sksurv/datasets/data/breast_cancer_GSE7390-metastasis.arff,sha256=Iz9MHAay7imf_8ug-YgfbtZqNWbMvsMLUATw0pi1JXA,264743
38
+ sksurv/datasets/data/flchain.arff,sha256=vyYA7EN90ZBx9zva2C3mgXgEV9EUHsNu1VGwAm5uV3M,343058
39
+ sksurv/datasets/data/whas500.arff,sha256=9kBAyROYh1E3gi7KMGqScgjfaJaAjNl2SvcGVyL6U9Y,27772
40
+ sksurv/datasets/data/veteran.arff,sha256=cdvJ4jXzzC7RCzolTjn5hcCSNG0chFc27SGxP74mNFY,5260
41
+ sksurv/io/arffwrite.py,sha256=fRJJ6h8Q4z5h9PNgzQgjLStYbVw1L38J2Qc3OKXFoWY,5431
42
+ sksurv/io/__init__.py,sha256=LacpKG9UKO_RefPXc6umPaGFGPOGzA-FZra_MCRWCxk,92
43
+ sksurv/io/arffread.py,sha256=Tz7D7BgsEcsC-7NRJjFziXyOO-jwVoj-QNRMmQkORPM,2638
44
+ sksurv/meta/__init__.py,sha256=VLA0VhLxZhF3z35md5Z4-nhw6BSSCfR6L7YOBGk1w1A,216
45
+ sksurv/meta/stacking.py,sha256=7dROmB9H-qfwWeCf9ueu9IEEsxDQOTNPK82nmH-EFlg,13164
46
+ sksurv/meta/ensemble_selection.py,sha256=cy4szNkw6KABLE7QjVkb6nMKV8YEWAunalM8SK0aSu8,26568
47
+ sksurv/meta/base.py,sha256=mV6653v4txKKHJqcJXVT-J-ARNN9rDfzIq02xoEy93I,1437
48
+ sksurv/linear_model/coxph.py,sha256=KFzVDP1TrNr9Hv08bCGsacTX0w_aE2jwsgMpCHe3R8A,22189
49
+ sksurv/linear_model/__init__.py,sha256=58Lt5Tj3xGqRS4uZfVR5avKQNZubHD6RSknVDyzLTso,152
50
+ sksurv/linear_model/coxnet.py,sha256=RgIomES97BcaM-RWmxmrP6AE3vkDaBsy4of727VsVfQ,22556
51
+ sksurv/linear_model/_coxnet.cpython-310-darwin.so,sha256=vslhJhPM6_P9BaXZi7-HU7JrgEGlZdKvUJVUcEY9kh4,131520
52
+ sksurv/linear_model/aft.py,sha256=1Vn_V-e5ffQhbIed34MZzZBt4RzvAcLaxI1VTOZrBEY,7558
53
+ sksurv/svm/naive_survival_svm.py,sha256=hx1C__lOT8hSV0g-YBI5reEgp9v4qQXOnvUlbVlHPwc,9319
54
+ sksurv/svm/__init__.py,sha256=7BRFkatw9wbtsY-aes9cnz31VPpIjZ-383LuDmucDsw,328
55
+ sksurv/svm/_minlip.cpython-310-darwin.so,sha256=Wb-VBUoBB_HymL6997p4c7waMfSts6BIGUw6EHdfraE,207088
56
+ sksurv/svm/_prsvm.cpython-310-darwin.so,sha256=XdUksm-wnwjwehGVlAxLwvEz2so-KvIIbW-mweuL-BY,206944
57
+ sksurv/svm/survival_svm.py,sha256=JGgUSft8p999DvZ0e617Ui2IEopt8kG3xspAJHt8CbU,44986
58
+ sksurv/svm/minlip.py,sha256=Hnx6t2jV1s-p1puebvsHImRCUuv5HpJ0u-5bC4Sh6A0,24771
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (78.0.2)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp310-cp310-macosx_11_0_arm64
5
5
  Generator: delocate 0.13.0
sksurv/__init__.py CHANGED
@@ -17,6 +17,7 @@ def _get_version(name):
17
17
 
18
18
 
19
19
  def show_versions():
20
+ """Print debugging information."""
20
21
  sys_info = {
21
22
  "Platform": platform.platform(),
22
23
  "Python version": f"{platform.python_implementation()} {platform.python_version()}",
@@ -60,14 +61,14 @@ def show_versions():
60
61
 
61
62
  @available_if(_final_estimator_has("predict_cumulative_hazard_function"))
62
63
  def predict_cumulative_hazard_function(self, X, **kwargs):
63
- """Predict cumulative hazard function.
64
+ r"""Predict cumulative hazard function for a pipeline.
64
65
 
65
66
  The cumulative hazard function for an individual
66
67
  with feature vector :math:`x` is defined as
67
68
 
68
69
  .. math::
69
70
 
70
- H(t \\mid x) = \\exp(x^\\top \\beta) H_0(t) ,
71
+ H(t \mid x) = \exp(x^\top \beta) H_0(t) ,
71
72
 
72
73
  where :math:`H_0(t)` is the baseline hazard function,
73
74
  estimated by Breslow's estimator.
@@ -80,7 +81,29 @@ def predict_cumulative_hazard_function(self, X, **kwargs):
80
81
  Returns
81
82
  -------
82
83
  cum_hazard : ndarray, shape = (n_samples,)
83
- Predicted cumulative hazard functions.
84
+ Predicted cumulative hazard functions. Each element is an instance
85
+ of :class:`sksurv.functions.StepFunction`.
86
+
87
+ See Also
88
+ --------
89
+ predict_survival_function : Predict survival function for a pipeline.
90
+
91
+ Examples
92
+ --------
93
+ >>> from sksurv.datasets import load_whas500
94
+ >>> from sksurv.linear_model import CoxPHSurvivalAnalysis
95
+ >>> from sksurv.preprocessing import OneHotEncoder
96
+ >>> from sklearn.pipeline import Pipeline
97
+ >>>
98
+ >>> X, y = load_whas500()
99
+ >>> pipe = Pipeline([('encode', OneHotEncoder()),
100
+ ... ('cox', CoxPHSurvivalAnalysis())])
101
+ >>> pipe.fit(X, y)
102
+ Pipeline(...)
103
+ >>> chf = pipe.predict_cumulative_hazard_function(X.iloc[:5])
104
+ >>> for fn in chf:
105
+ ... print(fn.x, fn.y)
106
+ [...]
84
107
  """
85
108
  Xt = X
86
109
  for _, _, transform in self._iter(with_final=False):
@@ -90,14 +113,14 @@ def predict_cumulative_hazard_function(self, X, **kwargs):
90
113
 
91
114
  @available_if(_final_estimator_has("predict_survival_function"))
92
115
  def predict_survival_function(self, X, **kwargs):
93
- """Predict survival function.
116
+ r"""Predict survival function for a pipeline.
94
117
 
95
118
  The survival function for an individual
96
119
  with feature vector :math:`x` is defined as
97
120
 
98
121
  .. math::
99
122
 
100
- S(t \\mid x) = S_0(t)^{\\exp(x^\\top \\beta)} ,
123
+ S(t \mid x) = S_0(t)^{\exp(x^\top \beta)} ,
101
124
 
102
125
  where :math:`S_0(t)` is the baseline survival function,
103
126
  estimated by Breslow's estimator.
@@ -110,7 +133,29 @@ def predict_survival_function(self, X, **kwargs):
110
133
  Returns
111
134
  -------
112
135
  survival : ndarray, shape = (n_samples,)
113
- Predicted survival functions.
136
+ Predicted survival functions. Each element is an instance
137
+ of :class:`sksurv.functions.StepFunction`.
138
+
139
+ See Also
140
+ --------
141
+ predict_cumulative_hazard_function : Predict cumulative hazard function for a pipeline.
142
+
143
+ Examples
144
+ --------
145
+ >>> from sksurv.datasets import load_whas500
146
+ >>> from sksurv.linear_model import CoxPHSurvivalAnalysis
147
+ >>> from sksurv.preprocessing import OneHotEncoder
148
+ >>> from sklearn.pipeline import Pipeline
149
+ >>>
150
+ >>> X, y = load_whas500()
151
+ >>> pipe = Pipeline([('encode', OneHotEncoder()),
152
+ ... ('cox', CoxPHSurvivalAnalysis())])
153
+ >>> pipe.fit(X, y)
154
+ Pipeline(...)
155
+ >>> surv_fn = pipe.predict_survival_function(X.iloc[:5])
156
+ >>> for fn in surv_fn:
157
+ ... print(fn.x, fn.y)
158
+ [...]
114
159
  """
115
160
  Xt = X
116
161
  for _, _, transform in self._iter(with_final=False):
sksurv/base.py CHANGED
@@ -44,7 +44,10 @@ class SurvivalAnalysisMixin:
44
44
 
45
45
  Returns
46
46
  -------
47
- survival : ndarray
47
+ survival : ndarray of StepFunction
48
+ If `return_array` is True, an array of shape (n_samples, n_unique_times)
49
+ containing the survival function values. Otherwise, a list of
50
+ :class:`sksurv.functions.StepFunction` instances.
48
51
  """
49
52
  return self._predict_function("get_survival_function", baseline_model, prediction, return_array)
50
53
 
@@ -66,7 +69,10 @@ class SurvivalAnalysisMixin:
66
69
 
67
70
  Returns
68
71
  -------
69
- cum_hazard : ndarray
72
+ cum_hazard : ndarray of StepFunction
73
+ If `return_array` is True, an array of shape (n_samples, n_unique_times)
74
+ containing the cumulative hazard function values. Otherwise, a list of
75
+ :class:`sksurv.functions.StepFunction` instances.
70
76
  """
71
77
  return self._predict_function("get_cumulative_hazard_function", baseline_model, prediction, return_array)
72
78
 
@@ -87,6 +93,10 @@ class SurvivalAnalysisMixin:
87
93
  -------
88
94
  cindex : float
89
95
  Estimated concordance index.
96
+
97
+ See also
98
+ --------
99
+ sksurv.metrics.concordance_index_censored : Computes the concordance index.
90
100
  """
91
101
  from .metrics import concordance_index_censored
92
102
 
sksurv/column.py CHANGED
@@ -42,27 +42,28 @@ def standardize_column(series_or_array, with_std=True):
42
42
 
43
43
 
44
44
  def standardize(table, with_std=True):
45
- """
46
- Perform Z-Normalization on each numeric column of the given table.
45
+ """Standardize numeric features by removing the mean and scaling to unit variance.
46
+
47
+ This function performs Z-Normalization on each numeric column of the given
48
+ table.
47
49
 
48
- If `table` is a pandas.DataFrame, only numeric columns are modified,
49
- all other columns remain unchanged. If `table` is a numpy.ndarray,
50
- it is only modified if it has numeric dtype, in which case the returned
51
- array will have floating point dtype.
50
+ If `table` is a :class:`pandas.DataFrame`, only numeric columns are modified;
51
+ all other columns remain unchanged. If `table` is a :class:`numpy.ndarray`,
52
+ it is only modified if it has a numeric dtype, in which case the returned
53
+ array will have a floating-point dtype.
52
54
 
53
55
  Parameters
54
56
  ----------
55
57
  table : pandas.DataFrame or numpy.ndarray
56
58
  Data to standardize.
57
-
58
59
  with_std : bool, optional, default: True
59
- If ``False`` data is only centered and not converted to unit variance.
60
+ If ``False``, data is only centered (mean removed) and not scaled to
61
+ unit variance.
60
62
 
61
63
  Returns
62
64
  -------
63
- normalized : pandas.DataFrame
64
- Table with numeric columns normalized.
65
- Categorical columns in the input table remain unchanged.
65
+ normalized : pandas.DataFrame or numpy.ndarray
66
+ The standardized data. The output type will be the same as the input type.
66
67
  """
67
68
  new_frame = _apply_along_column(table, standardize_column, with_std=with_std)
68
69
 
@@ -90,28 +91,30 @@ def _encode_categorical_series(series, allow_drop=True):
90
91
 
91
92
 
92
93
  def encode_categorical(table, columns=None, **kwargs):
93
- """
94
- Encode categorical columns with `M` categories into `M-1` columns according
95
- to the one-hot scheme.
94
+ """One-hot encode categorical features.
95
+
96
+ This function creates a binary column for each category and, by default,
97
+ drops one of the categories per feature: a column with `M` categories
98
+ is encoded as `M-1` integer columns according to the one-hot
99
+ scheme.
96
100
 
97
101
  Parameters
98
102
  ----------
99
- table : pandas.DataFrame
100
- Table with categorical columns to encode.
101
-
103
+ table : pandas.DataFrame or pandas.Series
104
+ Data with categorical columns to encode.
102
105
  columns : list-like, optional, default: None
103
106
  Column names in the DataFrame to be encoded.
104
- If `columns` is None then all the columns with
105
- `object` or `category` dtype will be converted.
106
-
107
- allow_drop : boolean, optional, default: True
107
+ If `columns` is `None`, all columns with `object` or `category`
108
+ dtype will be converted. This parameter is ignored if `table` is a
109
+ pandas.Series.
110
+ allow_drop : bool, optional, default: True
108
111
  Whether to allow dropping categorical columns that only consist
109
112
  of a single category.
110
113
 
111
114
  Returns
112
115
  -------
113
116
  encoded : pandas.DataFrame
114
- Table with categorical columns encoded as numeric.
117
+ The transformed data with categorical columns encoded as numeric.
115
118
  Numeric columns in the input table remain unchanged.
116
119
  """
117
120
  if isinstance(table, pd.Series):
@@ -165,19 +168,20 @@ def _get_dummies_1d(data, allow_drop=True):
165
168
 
166
169
 
167
170
  def categorical_to_numeric(table):
168
- """Encode categorical columns to numeric by converting each category to
169
- an integer value.
171
+ """Encode categorical features as integers.
172
+
173
+ This function converts each category to a unique integer value.
170
174
 
171
175
  Parameters
172
176
  ----------
173
- table : pandas.DataFrame
174
- Table with categorical columns to encode.
177
+ table : pandas.DataFrame or pandas.Series
178
+ Data with categorical columns to encode.
175
179
 
176
180
  Returns
177
181
  -------
178
- encoded : pandas.DataFrame
179
- Table with categorical columns encoded as numeric.
180
- Numeric columns in the input table remain unchanged.
182
+ encoded : pandas.DataFrame or pandas.Series
183
+ The transformed data with categorical columns encoded as integers.
184
+ The output type will be the same as the input type.
181
185
  """
182
186
 
183
187
  def transform(column):
sksurv/compare.py CHANGED
@@ -11,43 +11,43 @@ __all__ = ["compare_survival"]
11
11
 
12
12
 
13
13
  def compare_survival(y, group_indicator, return_stats=False):
14
- """K-sample log-rank hypothesis test of identical survival functions.
14
+ """Compare survival functions of two or more groups using the log-rank test.
15
15
 
16
- Compares the pooled hazard rate with each group-specific
17
- hazard rate. The alternative hypothesis is that the hazard
18
- rate of at least one group differs from the others at some time.
16
+ The log-rank test is a non-parametric hypothesis test for comparing the
17
+ survival functions of two or more independent groups. The null hypothesis is
18
+ that the survival functions of the groups are identical. The alternative
19
+ hypothesis is that at least one survival function differs from the others.
20
+
21
+ The test statistic is approximately chi-squared distributed with :math:`K-1`
22
+ degrees of freedom, where :math:`K` is the number of groups.
19
23
 
20
24
  See [1]_ for more details.
21
25
 
22
26
  Parameters
23
27
  ----------
24
28
  y : structured array, shape = (n_samples,)
25
- A structured array containing the binary event indicator
26
- as first field, and time of event or time of censoring as
27
- second field.
28
-
29
+ A structured array with two fields. The first field is a boolean
30
+ where ``True`` indicates an event and ``False`` indicates right-censoring.
31
+ The second field is a float with the time of event or time of censoring.
29
32
  group_indicator : array-like, shape = (n_samples,)
30
33
  Group membership of each sample.
31
-
32
34
  return_stats : bool, optional, default: False
33
- Whether to return a data frame with statistics for each group
34
- and the covariance matrix of the test statistic.
35
+ Whether to return a data frame with statistics for each group and the
36
+ covariance matrix of the test statistic.
35
37
 
36
38
  Returns
37
39
  -------
38
40
  chisq : float
39
- Test statistic.
41
+ The test statistic.
40
42
  pvalue : float
41
- Two-sided p-value with respect to the null hypothesis
42
- that the hazard rates across all groups are equal.
43
- stats : pandas.DataFrame
44
- Summary statistics for each group: number of samples,
45
- observed number of events, expected number of events,
46
- and test statistic.
47
- Only provided if `return_stats` is True.
48
- covariance : array, shape=(n_groups, n_groups)
49
- Covariance matrix of the test statistic.
50
- Only provided if `return_stats` is True.
43
+ The two-sided p-value for the test.
44
+ stats : pandas.DataFrame, optional
45
+ A DataFrame with summary statistics for each group. This includes the
46
+ number of samples, observed number of events, expected number of events,
47
+ and the test statistic. Only returned if ``return_stats`` is ``True``.
48
+ covariance : ndarray, shape=(n_groups, n_groups), optional
49
+ The covariance matrix of the test statistic. Only returned if
50
+ ``return_stats`` is ``True``.
51
51
 
52
52
  References
53
53
  ----------