lifelines 0.27.6__py3-none-any.whl → 0.27.7__py3-none-any.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.
lifelines/__init__.py CHANGED
@@ -1,7 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # pylint: skip-file
3
3
 
4
- from typing import List
5
4
  from lifelines.fitters.weibull_fitter import WeibullFitter
6
5
  from lifelines.fitters.exponential_fitter import ExponentialFitter
7
6
  from lifelines.fitters.nelson_aalen_fitter import NelsonAalenFitter
@@ -23,7 +22,7 @@ from lifelines.fitters.generalized_gamma_regression_fitter import GeneralizedGam
23
22
  from lifelines.fitters.spline_fitter import SplineFitter
24
23
  from lifelines.fitters.mixture_cure_fitter import MixtureCureFitter
25
24
  from lifelines.fitters.crc_spline_fitter import CRCSplineFitter
26
-
25
+ from lifelines import datasets
27
26
 
28
27
  from lifelines.version import __version__
29
28
 
@@ -107,6 +107,49 @@ class ProportionalHazardMixin:
107
107
 
108
108
  for variable in self.params_.index.intersection(columns or self.params_.index):
109
109
  minumum_observed_p_value = test_results.summary.loc[variable, "p"].min()
110
+
111
+ # plot is done (regardless of test result) whenever `show_plots = True`
112
+ if show_plots:
113
+ axes.append([])
114
+ print()
115
+ print(" Bootstrapping lowess lines. May take a moment...")
116
+ print()
117
+ from matplotlib import pyplot as plt
118
+
119
+ fig = plt.figure()
120
+
121
+ # plot variable against all time transformations.
122
+ for i, (transform_name, transformer) in enumerate(TimeTransformers().iter(["rank", "km"]), start=1):
123
+ p_value = test_results.summary.loc[(variable, transform_name), "p"]
124
+
125
+ ax = fig.add_subplot(1, 2, i)
126
+
127
+ y = residuals_and_duration[variable]
128
+ tt = transformer(self.durations, self.event_observed, self.weights)[self.event_observed.values]
129
+
130
+ ax.scatter(tt, y, alpha=0.75)
131
+
132
+ y_lowess = lowess(tt.values, y.values)
133
+ ax.plot(tt, y_lowess, color="k", alpha=1.0, linewidth=2)
134
+
135
+ # bootstrap some possible other lowess lines. This is an approximation of the 100% confidence intervals
136
+ for _ in range(plot_n_bootstraps):
137
+ ix = sorted(np.random.choice(n, n))
138
+ tt_ = tt.values[ix]
139
+ y_lowess = lowess(tt_, y.values[ix])
140
+ ax.plot(tt_, y_lowess, color="k", alpha=0.30)
141
+
142
+ best_xlim = ax.get_xlim()
143
+ ax.hlines(0, 0, tt.max(), linestyles="dashed", linewidths=1)
144
+ ax.set_xlim(best_xlim)
145
+
146
+ ax.set_xlabel("%s-transformed time\n(p=%.4f)" % (transform_name, p_value), fontsize=10)
147
+ axes[-1].append(ax)
148
+
149
+ fig.suptitle("Scaled Schoenfeld residuals of '%s'" % variable, fontsize=14)
150
+ plt.tight_layout()
151
+ plt.subplots_adjust(top=0.90)
152
+
110
153
  if np.round(minumum_observed_p_value, 2) > p_value_threshold:
111
154
  continue
112
155
 
@@ -181,48 +224,9 @@ class ProportionalHazardMixin:
181
224
  ),
182
225
  end="\n\n",
183
226
  )
227
+ #################
184
228
 
185
- if show_plots:
186
- axes.append([])
187
- print()
188
- print(" Bootstrapping lowess lines. May take a moment...")
189
- print()
190
- from matplotlib import pyplot as plt
191
-
192
- fig = plt.figure()
193
-
194
- # plot variable against all time transformations.
195
- for i, (transform_name, transformer) in enumerate(TimeTransformers().iter(["rank", "km"]), start=1):
196
- p_value = test_results.summary.loc[(variable, transform_name), "p"]
197
-
198
- ax = fig.add_subplot(1, 2, i)
199
-
200
- y = residuals_and_duration[variable]
201
- tt = transformer(self.durations, self.event_observed, self.weights)[self.event_observed.values]
202
-
203
- ax.scatter(tt, y, alpha=0.75)
204
-
205
- y_lowess = lowess(tt.values, y.values)
206
- ax.plot(tt, y_lowess, color="k", alpha=1.0, linewidth=2)
207
-
208
- # bootstrap some possible other lowess lines. This is an approximation of the 100% confidence intervals
209
- for _ in range(plot_n_bootstraps):
210
- ix = sorted(np.random.choice(n, n))
211
- tt_ = tt.values[ix]
212
- y_lowess = lowess(tt_, y.values[ix])
213
- ax.plot(tt_, y_lowess, color="k", alpha=0.30)
214
-
215
- best_xlim = ax.get_xlim()
216
- ax.hlines(0, 0, tt.max(), linestyles="dashed", linewidths=1)
217
- ax.set_xlim(best_xlim)
218
-
219
- ax.set_xlabel("%s-transformed time\n(p=%.4f)" % (transform_name, p_value), fontsize=10)
220
- axes[-1].append(ax)
221
-
222
- fig.suptitle("Scaled Schoenfeld residuals of '%s'" % variable, fontsize=14)
223
- plt.tight_layout()
224
- plt.subplots_adjust(top=0.90)
225
-
229
+
226
230
  if advice and counter > 0:
227
231
  print(
228
232
  dedent(
lifelines/version.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  from __future__ import unicode_literals
3
3
 
4
- __version__ = "0.27.6"
4
+ __version__ = "0.27.7"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lifelines
3
- Version: 0.27.6
3
+ Version: 0.27.7
4
4
  Summary: Survival analysis in Python, including Kaplan Meier, Nelson Aalen and regression
5
5
  Home-page: https://github.com/CamDavidsonPilon/lifelines
6
6
  Author: Cameron Davidson-Pilon
@@ -1,11 +1,11 @@
1
- lifelines/__init__.py,sha256=qPF0ennAJGEAK-s63Z0e4DHiWnfRT98slfHjR-tjGw4,2235
1
+ lifelines/__init__.py,sha256=F_sKrawq6L4GwTPgOu4FjoGUKQ2gfelAVIQOW1Ee8Ao,2241
2
2
  lifelines/calibration.py,sha256=Luii7bkJ2YB0jpuOYYhI22aUyEc1gLsS10Pno6Sqo98,4113
3
3
  lifelines/exceptions.py,sha256=Kf6GN2vB-SHde2mbPomj2PhpnCvCBOSTUZLY1jwOw-U,514
4
4
  lifelines/generate_datasets.py,sha256=WsvvrZt0jEYQ7-Fp53vrCq7MzmAM2pPUSoCaiQRwN5g,10155
5
5
  lifelines/metrics.py,sha256=1NY5CAwETP7C8lIUjmQz2ye648W64oChs2zdi-rqEzc,1889
6
6
  lifelines/plotting.py,sha256=AKRFHz0ye_pu5kE_nod3kM5AhQKL8h1tdrHt77nDDa4,33150
7
7
  lifelines/statistics.py,sha256=cOszUYz87elnbTAt6V3fTrHwPjB9HFI1hxjLvKypS6k,35129
8
- lifelines/version.py,sha256=MOtugNLPfWQShXfz30m0B5NZNwkJ07m3v5VhpK0fUjU,88
8
+ lifelines/version.py,sha256=5c99jzzH3waN_PF9HgeSaexk7Z6Rucqb2uRdXVlPMt4,88
9
9
  lifelines/datasets/ACTG175.csv,sha256=VvujH6DXv7_5ZntxSf2WqXw1LnKqWChxpiqTXoEvDgc,185144
10
10
  lifelines/datasets/CuZn-LeftCensoredDataset.csv,sha256=PxTdZcJPPbhtaadpHjhMFVcUxmSn84BuDarujZIJpm4,1996
11
11
  lifelines/datasets/__init__.py,sha256=9OIUjJUP6mK4oiFIRwHTh9tI5icDj4z8owUfPPDiY8c,19990
@@ -52,7 +52,7 @@ lifelines/fitters/log_logistic_aft_fitter.py,sha256=cw179z0_IqvuWgOORHSZ1lBiidHc
52
52
  lifelines/fitters/log_logistic_fitter.py,sha256=iTH97i9TrLp5IVBIZHC8nx5rvSn2-KM-wfv1wR_YSPU,4004
53
53
  lifelines/fitters/log_normal_aft_fitter.py,sha256=aOcdMR8T4vhy2BKGebrpEJD_lTZIQQ5VsrnuuKkU0RA,7890
54
54
  lifelines/fitters/log_normal_fitter.py,sha256=NLn1DCxJ9WJrVaairJPcOu_lShko_-vwoXw6goRR42w,3557
55
- lifelines/fitters/mixins.py,sha256=_ht2WvDztBsvgGQ5vmprhfiChEP5DfdwNQfa9JkyxtY,12399
55
+ lifelines/fitters/mixins.py,sha256=6k5-g8cit8ODbU7PbVD9tfYsY0jpde0HID3wJQ5kz1k,12527
56
56
  lifelines/fitters/mixture_cure_fitter.py,sha256=UetFlv9EfFYMDt95M2iR354lna5RKeWtO_lkoaMmoZE,5416
57
57
  lifelines/fitters/nelson_aalen_fitter.py,sha256=UNlEX5wR6xsUmEmJ2n2MEqblz-KvGmvlh8eGHfuQf6Y,10666
58
58
  lifelines/fitters/npmle.py,sha256=HV3yeu1byVv5oBSdv5TuLUg2X5NUxydxj8-h_xYScB0,10143
@@ -68,8 +68,8 @@ lifelines/utils/lowess.py,sha256=MMydVcnbxqIgsiNcIgVUFtlFycD7v3ezwEGpituvBHs,254
68
68
  lifelines/utils/printer.py,sha256=-nXxu02gs0kaKfoQQ65sH-I45tGmgoFeOOIUSEc53iE,5861
69
69
  lifelines/utils/safe_exp.py,sha256=HCCAkwQTx6G2qRC03v9Q_GWqVj8at1Eac1JVrMgS9hg,4350
70
70
  lifelines/utils/sklearn_adapter.py,sha256=S5qotbZ1hf1fhFBsx39Yd_NpA31jB9HhRiLjE8TWlhw,4202
71
- lifelines-0.27.6.dist-info/LICENSE,sha256=AasDeD139SnTdfXbKgN4BMyMgBlRy9YFs60tNrB4wf0,1079
72
- lifelines-0.27.6.dist-info/METADATA,sha256=eACHqn7mITMlQDm6m_9UODXnQqkZ3g9HclP1ZrT4z9c,3297
73
- lifelines-0.27.6.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
74
- lifelines-0.27.6.dist-info/top_level.txt,sha256=3i57Z4mtpc6jWrsW0n-_o9Y7CpzytMTeLMPJBHYAo0o,10
75
- lifelines-0.27.6.dist-info/RECORD,,
71
+ lifelines-0.27.7.dist-info/LICENSE,sha256=AasDeD139SnTdfXbKgN4BMyMgBlRy9YFs60tNrB4wf0,1079
72
+ lifelines-0.27.7.dist-info/METADATA,sha256=N0RFCC7WLIaqHa6CYMMvvMkYVWE-Er77nqFYI6m3uWI,3297
73
+ lifelines-0.27.7.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
74
+ lifelines-0.27.7.dist-info/top_level.txt,sha256=3i57Z4mtpc6jWrsW0n-_o9Y7CpzytMTeLMPJBHYAo0o,10
75
+ lifelines-0.27.7.dist-info/RECORD,,