lifelines 0.28.0__py3-none-any.whl → 0.30.0__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/datasets/__init__.py +1 -1
- lifelines/fitters/__init__.py +6 -6
- lifelines/fitters/aalen_additive_fitter.py +2 -2
- lifelines/fitters/cox_time_varying_fitter.py +1 -1
- lifelines/fitters/coxph_fitter.py +16 -6
- lifelines/fitters/mixins.py +3 -3
- lifelines/fitters/nelson_aalen_fitter.py +1 -1
- lifelines/fitters/npmle.py +1 -1
- lifelines/fitters/piecewise_exponential_regression_fitter.py +1 -1
- lifelines/generate_datasets.py +6 -6
- lifelines/statistics.py +4 -4
- lifelines/utils/__init__.py +8 -8
- lifelines/version.py +1 -1
- {lifelines-0.28.0.dist-info → lifelines-0.30.0.dist-info}/METADATA +10 -10
- {lifelines-0.28.0.dist-info → lifelines-0.30.0.dist-info}/RECORD +18 -18
- {lifelines-0.28.0.dist-info → lifelines-0.30.0.dist-info}/WHEEL +1 -1
- {lifelines-0.28.0.dist-info → lifelines-0.30.0.dist-info}/LICENSE +0 -0
- {lifelines-0.28.0.dist-info → lifelines-0.30.0.dist-info}/top_level.txt +0 -0
lifelines/datasets/__init__.py
CHANGED
lifelines/fitters/__init__.py
CHANGED
|
@@ -18,7 +18,7 @@ from autograd.misc import flatten
|
|
|
18
18
|
import autograd.numpy as anp
|
|
19
19
|
|
|
20
20
|
from scipy.optimize import minimize, root_scalar
|
|
21
|
-
from scipy.integrate import
|
|
21
|
+
from scipy.integrate import trapezoid
|
|
22
22
|
from scipy import stats
|
|
23
23
|
|
|
24
24
|
import pandas as pd
|
|
@@ -573,7 +573,7 @@ class ParametricUnivariateFitter(UnivariateFitter):
|
|
|
573
573
|
|
|
574
574
|
# convergence successful.
|
|
575
575
|
# I still need to check for ~np.isnan(minimizing_results.x).any() since minimize will happily
|
|
576
|
-
# return nans even when criteria is
|
|
576
|
+
# return nans even when criteria is satisfied.
|
|
577
577
|
if minimizing_results and minimizing_results.success and ~np.isnan(minimizing_results.x).any():
|
|
578
578
|
sol = utils._to_1d_array(minimizing_results.x)
|
|
579
579
|
# pylint: disable=no-value-for-parameter
|
|
@@ -876,7 +876,7 @@ class ParametricUnivariateFitter(UnivariateFitter):
|
|
|
876
876
|
length n, the end of the period the subject experienced the event in. If the value is equal to the corresponding value in lower_bound, then
|
|
877
877
|
the individual's event was observed (not censored).
|
|
878
878
|
event_observed: numpy array or pd.Series, optional
|
|
879
|
-
length n, if left optional, infer from ``lower_bound`` and ``
|
|
879
|
+
length n, if left optional, infer from ``lower_bound`` and ``upper_bound`` (if lower_bound==upper_bound then event observed, if lower_bound < upper_bound, then event censored)
|
|
880
880
|
timeline: list, optional
|
|
881
881
|
return the estimate at the values in timeline (positively increasing)
|
|
882
882
|
label: string, optional
|
|
@@ -1925,7 +1925,7 @@ class ParametricRegressionFitter(RegressionFitter):
|
|
|
1925
1925
|
def _fit_model(
|
|
1926
1926
|
self, likelihood, Ts, Xs, E, weights, entries, fit_options, show_progress=False, user_supplied_initial_point=None
|
|
1927
1927
|
):
|
|
1928
|
-
|
|
1928
|
+
initial_points_as_arrays, unflatten_array_to_dict = self._prepare_initial_points(
|
|
1929
1929
|
user_supplied_initial_point, Ts, E, entries, weights, Xs
|
|
1930
1930
|
)
|
|
1931
1931
|
|
|
@@ -1939,7 +1939,7 @@ class ParametricRegressionFitter(RegressionFitter):
|
|
|
1939
1939
|
|
|
1940
1940
|
minimum_ll = np.inf
|
|
1941
1941
|
minimum_results = None
|
|
1942
|
-
for _initial_point in
|
|
1942
|
+
for _initial_point in initial_points_as_arrays:
|
|
1943
1943
|
|
|
1944
1944
|
if _initial_point.shape[0] != Xs.columns.size:
|
|
1945
1945
|
raise ValueError("initial_point is not the correct shape.")
|
|
@@ -2507,7 +2507,7 @@ class ParametricRegressionFitter(RegressionFitter):
|
|
|
2507
2507
|
warnings.warn("""Approximating the expected value using trapezoid rule.\n""", exceptions.ApproximationWarning)
|
|
2508
2508
|
subjects = utils._get_index(X)
|
|
2509
2509
|
v = self.predict_survival_function(X, conditional_after=conditional_after)[subjects]
|
|
2510
|
-
return pd.Series(
|
|
2510
|
+
return pd.Series(trapezoid(v.values.T, v.index), index=subjects).squeeze()
|
|
2511
2511
|
|
|
2512
2512
|
@property
|
|
2513
2513
|
def median_survival_time_(self):
|
|
@@ -6,7 +6,7 @@ import time
|
|
|
6
6
|
import numpy as np
|
|
7
7
|
import pandas as pd
|
|
8
8
|
from numpy.linalg import LinAlgError
|
|
9
|
-
from scipy.integrate import
|
|
9
|
+
from scipy.integrate import trapezoid
|
|
10
10
|
|
|
11
11
|
from lifelines.fitters import RegressionFitter
|
|
12
12
|
from lifelines.utils.printer import Printer
|
|
@@ -396,7 +396,7 @@ It's important to know that the naive variance estimates of the coefficients are
|
|
|
396
396
|
"""
|
|
397
397
|
index = _get_index(X)
|
|
398
398
|
t = self._index
|
|
399
|
-
return pd.Series(
|
|
399
|
+
return pd.Series(trapezoid(self.predict_survival_function(X)[index].values.T, t), index=index)
|
|
400
400
|
|
|
401
401
|
def _compute_confidence_intervals(self):
|
|
402
402
|
ci = 100 * (1 - self.alpha)
|
|
@@ -801,7 +801,7 @@ See https://stats.stackexchange.com/questions/11109/how-to-deal-with-perfect-sep
|
|
|
801
801
|
hazards = self.predict_partial_hazard(tv_data).values
|
|
802
802
|
|
|
803
803
|
unique_death_times = np.unique(stop[events.values])
|
|
804
|
-
baseline_hazard_ = pd.DataFrame(np.zeros_like(unique_death_times), index=unique_death_times, columns=["baseline hazard"])
|
|
804
|
+
baseline_hazard_ = pd.DataFrame(np.zeros_like(unique_death_times).astype(float), index=unique_death_times, columns=["baseline hazard"])
|
|
805
805
|
|
|
806
806
|
for t in unique_death_times:
|
|
807
807
|
ix = (start.values < t) & (t <= stop.values)
|
|
@@ -9,7 +9,7 @@ import time
|
|
|
9
9
|
from numpy import dot, einsum, log, exp, zeros, arange, multiply, ndarray
|
|
10
10
|
import numpy as np
|
|
11
11
|
from scipy.linalg import solve as spsolve, LinAlgError, norm, inv
|
|
12
|
-
from scipy.integrate import
|
|
12
|
+
from scipy.integrate import trapezoid
|
|
13
13
|
from scipy import stats
|
|
14
14
|
from pandas import DataFrame, Series, Index
|
|
15
15
|
import pandas as pd
|
|
@@ -2514,7 +2514,7 @@ See https://stats.stackexchange.com/q/11109/11867 for more.\n",
|
|
|
2514
2514
|
"""
|
|
2515
2515
|
subjects = utils._get_index(X)
|
|
2516
2516
|
v = self.predict_survival_function(X, conditional_after=conditional_after)[subjects]
|
|
2517
|
-
return pd.Series(
|
|
2517
|
+
return pd.Series(trapezoid(v.values.T, v.index), index=subjects)
|
|
2518
2518
|
|
|
2519
2519
|
def _compute_baseline_hazard(self, partial_hazards: DataFrame, name: Any) -> pd.DataFrame:
|
|
2520
2520
|
# https://stats.stackexchange.com/questions/46532/cox-baseline-hazard
|
|
@@ -2991,7 +2991,11 @@ class ParametricSplinePHFitter(ParametricCoxModelFitter, SplineFitterMixin):
|
|
|
2991
2991
|
|
|
2992
2992
|
@staticmethod
|
|
2993
2993
|
def _strata_labeler(stratum, i):
|
|
2994
|
-
|
|
2994
|
+
try:
|
|
2995
|
+
return "s%s_phi%d_" % (tuple(str(s) for s in stratum), i)
|
|
2996
|
+
except:
|
|
2997
|
+
# singleton
|
|
2998
|
+
return "s%s_phi%d_" % (stratum, i)
|
|
2995
2999
|
|
|
2996
3000
|
@property
|
|
2997
3001
|
def _fitted_parameter_names(self):
|
|
@@ -3112,7 +3116,11 @@ class ParametricPiecewiseBaselinePHFitter(ParametricCoxModelFitter, Proportional
|
|
|
3112
3116
|
|
|
3113
3117
|
@staticmethod
|
|
3114
3118
|
def _strata_labeler(stratum, i):
|
|
3115
|
-
|
|
3119
|
+
try:
|
|
3120
|
+
return "s%s_lambda%d_" % (tuple(str(s) for s in stratum), i)
|
|
3121
|
+
except:
|
|
3122
|
+
# singleton
|
|
3123
|
+
return "s%s_lambda%d_" % (stratum, i)
|
|
3116
3124
|
|
|
3117
3125
|
@property
|
|
3118
3126
|
def _fitted_parameter_names(self):
|
|
@@ -3223,7 +3231,7 @@ class ParametricPiecewiseBaselinePHFitter(ParametricCoxModelFitter, Proportional
|
|
|
3223
3231
|
|
|
3224
3232
|
for stratum, stratified_X in df.groupby(self.strata):
|
|
3225
3233
|
log_lambdas_ = anp.array(
|
|
3226
|
-
[0] + [self.params_[self._strata_labeler(stratum, i)][0] for i in range(2, self.n_breakpoints + 2)]
|
|
3234
|
+
[0] + [self.params_.loc[self._strata_labeler(stratum, i)].iloc[0] for i in range(2, self.n_breakpoints + 2)]
|
|
3227
3235
|
)
|
|
3228
3236
|
lambdas_ = np.exp(log_lambdas_)
|
|
3229
3237
|
|
|
@@ -3237,7 +3245,9 @@ class ParametricPiecewiseBaselinePHFitter(ParametricCoxModelFitter, Proportional
|
|
|
3237
3245
|
return cumulative_hazard
|
|
3238
3246
|
|
|
3239
3247
|
else:
|
|
3240
|
-
log_lambdas_ = np.array(
|
|
3248
|
+
log_lambdas_ = np.array(
|
|
3249
|
+
[0] + [self.params_.loc[param].iloc[0] for param in self._fitted_parameter_names if param != "beta_"]
|
|
3250
|
+
)
|
|
3241
3251
|
lambdas_ = np.exp(log_lambdas_)
|
|
3242
3252
|
|
|
3243
3253
|
Xs = self.regressors.transform_df(df)
|
lifelines/fitters/mixins.py
CHANGED
|
@@ -110,7 +110,7 @@ class ProportionalHazardMixin:
|
|
|
110
110
|
axes = []
|
|
111
111
|
|
|
112
112
|
for variable in self.params_.index.intersection(columns or self.params_.index):
|
|
113
|
-
|
|
113
|
+
minimum_observed_p_value = test_results.summary.loc[variable, "p"].min()
|
|
114
114
|
|
|
115
115
|
# plot is done (regardless of test result) whenever `show_plots = True`
|
|
116
116
|
if show_plots:
|
|
@@ -154,7 +154,7 @@ class ProportionalHazardMixin:
|
|
|
154
154
|
plt.tight_layout()
|
|
155
155
|
plt.subplots_adjust(top=0.90)
|
|
156
156
|
|
|
157
|
-
if np.round(
|
|
157
|
+
if np.round(minimum_observed_p_value, 2) > p_value_threshold:
|
|
158
158
|
continue
|
|
159
159
|
|
|
160
160
|
counter += 1
|
|
@@ -182,7 +182,7 @@ class ProportionalHazardMixin:
|
|
|
182
182
|
print()
|
|
183
183
|
print(
|
|
184
184
|
"%d. Variable '%s' failed the non-proportional test: p-value is %s."
|
|
185
|
-
% (counter, variable, format_p_value(4)(
|
|
185
|
+
% (counter, variable, format_p_value(4)(minimum_observed_p_value)),
|
|
186
186
|
end="\n\n",
|
|
187
187
|
)
|
|
188
188
|
|
lifelines/fitters/npmle.py
CHANGED
|
@@ -291,7 +291,7 @@ def reconstruct_survival_function(
|
|
|
291
291
|
|
|
292
292
|
# First backfill at events between known observations
|
|
293
293
|
# Second fill all events _outside_ known obs with running_sum
|
|
294
|
-
return full_dataframe.combine_first(df).bfill().fillna(running_sum).clip(lower=0.0)
|
|
294
|
+
return full_dataframe.combine_first(df).astype(float).bfill().fillna(running_sum).clip(lower=0.0)
|
|
295
295
|
|
|
296
296
|
|
|
297
297
|
def npmle_compute_confidence_intervals(left, right, mle_, alpha=0.05, samples=1000):
|
|
@@ -66,7 +66,7 @@ class PiecewiseExponentialRegressionFitter(ParametricRegressionFitter):
|
|
|
66
66
|
coef_penalty = 0
|
|
67
67
|
if self.penalizer > 0:
|
|
68
68
|
for i in range(params_stacked.shape[1]):
|
|
69
|
-
if not self._cols_to_not_penalize[i]:
|
|
69
|
+
if not self._cols_to_not_penalize.iloc[i]:
|
|
70
70
|
coef_penalty = coef_penalty + (params_stacked[:, i]).var()
|
|
71
71
|
|
|
72
72
|
return neg_ll + self.penalizer * coef_penalty
|
lifelines/generate_datasets.py
CHANGED
|
@@ -5,7 +5,7 @@ import pandas as pd
|
|
|
5
5
|
|
|
6
6
|
from scipy import stats
|
|
7
7
|
from scipy.optimize import newton
|
|
8
|
-
from scipy.integrate import
|
|
8
|
+
from scipy.integrate import cumulative_trapezoid
|
|
9
9
|
|
|
10
10
|
random = np.random
|
|
11
11
|
|
|
@@ -172,7 +172,7 @@ def constant_coefficients(d, timelines, constant=True, independent=0):
|
|
|
172
172
|
timelines: the observational times
|
|
173
173
|
constant: True for constant coefficients
|
|
174
174
|
independent: the number of coffients to set to 0 (covariate is ind of survival), or
|
|
175
|
-
a list of covariates to make
|
|
175
|
+
a list of covariates to make independent.
|
|
176
176
|
|
|
177
177
|
returns a matrix (t,d+1) of coefficients
|
|
178
178
|
"""
|
|
@@ -187,7 +187,7 @@ def time_varying_coefficients(d, timelines, constant=False, independent=0, randg
|
|
|
187
187
|
timelines: the observational times
|
|
188
188
|
constant: True for constant coefficients
|
|
189
189
|
independent: the number of coffients to set to 0 (covariate is ind of survival), or
|
|
190
|
-
a list of covariates to make
|
|
190
|
+
a list of covariates to make independent.
|
|
191
191
|
randgen: how scalar coefficients (betas) are sampled.
|
|
192
192
|
|
|
193
193
|
returns a matrix (t,d+1) of coefficients
|
|
@@ -221,7 +221,7 @@ def generate_hazard_rates(n, d, timelines, constant=False, independent=0, n_bina
|
|
|
221
221
|
n: the number of instances
|
|
222
222
|
d: the number of covariates
|
|
223
223
|
lifelines: the observational times
|
|
224
|
-
constant: make the
|
|
224
|
+
constant: make the coefficients constant (not time dependent)
|
|
225
225
|
n_binary: the number of binary covariates
|
|
226
226
|
model: from ["aalen", "cox"]
|
|
227
227
|
|
|
@@ -253,7 +253,7 @@ def generate_random_lifetimes(hazard_rates, timelines, size=1, censor=None):
|
|
|
253
253
|
timelines: (t,) the observation times
|
|
254
254
|
size: the number to return, per hardard rate
|
|
255
255
|
censor: If True, adds uniform censoring between timelines.max() and 0
|
|
256
|
-
If a
|
|
256
|
+
If a positive number, censors all events above that value.
|
|
257
257
|
If (n,) np.array >=0 , censor elementwise.
|
|
258
258
|
|
|
259
259
|
|
|
@@ -308,7 +308,7 @@ def cumulative_integral(fx, x):
|
|
|
308
308
|
fx: (n,d) numpy array, what you want to integral of
|
|
309
309
|
x: (n,) numpy array, location to integrate over.
|
|
310
310
|
"""
|
|
311
|
-
return
|
|
311
|
+
return cumulative_trapezoid(fx.T, x, initial=0).T
|
|
312
312
|
|
|
313
313
|
|
|
314
314
|
def construct_survival_curves(hazard_rates, timelines):
|
lifelines/statistics.py
CHANGED
|
@@ -111,14 +111,14 @@ class StatisticalResult:
|
|
|
111
111
|
|
|
112
112
|
"""
|
|
113
113
|
if style is not None:
|
|
114
|
-
self._print_specific_style(style)
|
|
114
|
+
self._print_specific_style(style, decimals=decimals, **kwargs)
|
|
115
115
|
else:
|
|
116
116
|
try:
|
|
117
117
|
from IPython.display import display
|
|
118
118
|
|
|
119
119
|
display(self)
|
|
120
120
|
except ImportError:
|
|
121
|
-
self._ascii_print()
|
|
121
|
+
self._ascii_print(decimals=decimals, **kwargs)
|
|
122
122
|
|
|
123
123
|
def _html_print(self, decimals=2, **kwargs):
|
|
124
124
|
print(self.to_html(decimals, **kwargs))
|
|
@@ -835,7 +835,7 @@ def multivariate_logrank_test(
|
|
|
835
835
|
assert abs(Z_j.sum()) < 10e-8, "Sum is not zero." # this should move to a test eventually.
|
|
836
836
|
|
|
837
837
|
# compute covariance matrix
|
|
838
|
-
factor = (((n_i - d_i) / (n_i - 1)).replace([np.inf, np.nan], 1)) * d_i / n_i
|
|
838
|
+
factor = (((n_i - d_i) / (n_i - 1)).replace([np.inf, np.nan], 1)) * d_i / n_i**2
|
|
839
839
|
n_ij["_"] = n_i.values
|
|
840
840
|
V_ = (n_ij.mul(w_i, axis=0)).mul(np.sqrt(factor), axis="index").fillna(0) # weighted V_
|
|
841
841
|
V = -np.dot(V_.T, V_)
|
|
@@ -923,7 +923,7 @@ def proportional_hazard_test(
|
|
|
923
923
|
def compute_statistic(times, resids, n_deaths):
|
|
924
924
|
demeaned_times = times - times.mean()
|
|
925
925
|
T = (demeaned_times.values[:, None] * resids.values).sum(0) ** 2 / (
|
|
926
|
-
n_deaths * (fitted_cox_model.standard_errors_
|
|
926
|
+
n_deaths * (fitted_cox_model.standard_errors_**2) * (demeaned_times**2).sum()
|
|
927
927
|
)
|
|
928
928
|
return T
|
|
929
929
|
|
lifelines/utils/__init__.py
CHANGED
|
@@ -11,7 +11,7 @@ import warnings
|
|
|
11
11
|
from numpy import ndarray
|
|
12
12
|
import numpy as np
|
|
13
13
|
|
|
14
|
-
from scipy.integrate import quad,
|
|
14
|
+
from scipy.integrate import quad, trapezoid
|
|
15
15
|
from scipy.linalg import solve
|
|
16
16
|
from scipy import stats
|
|
17
17
|
|
|
@@ -266,7 +266,7 @@ def _expected_value_of_survival_up_to_t(model_or_survival_function, t: float = n
|
|
|
266
266
|
)
|
|
267
267
|
sf = model_or_survival_function.loc[:t]
|
|
268
268
|
sf = pd.concat((sf, pd.DataFrame([1], index=[0], columns=sf.columns))).sort_index()
|
|
269
|
-
return
|
|
269
|
+
return trapezoid(y=sf.values[:, 0], x=sf.index)
|
|
270
270
|
elif isinstance(model_or_survival_function, lifelines.fitters.UnivariateFitter):
|
|
271
271
|
# lifelines model
|
|
272
272
|
model = model_or_survival_function
|
|
@@ -313,7 +313,7 @@ def _expected_value_of_survival_squared_up_to_t(
|
|
|
313
313
|
sf = model_or_survival_function.loc[:t]
|
|
314
314
|
sf = pd.concat((sf, pd.DataFrame([1], index=[0], columns=sf.columns))).sort_index()
|
|
315
315
|
sf_tau = sf * sf.index.values[:, None]
|
|
316
|
-
return 2 *
|
|
316
|
+
return 2 * trapezoid(y=sf_tau.values[:, 0], x=sf_tau.index)
|
|
317
317
|
elif isinstance(model_or_survival_function, lifelines.fitters.UnivariateFitter):
|
|
318
318
|
# lifelines model
|
|
319
319
|
model = model_or_survival_function
|
|
@@ -556,7 +556,7 @@ def _group_event_table_by_intervals(event_table, intervals) -> pd.DataFrame:
|
|
|
556
556
|
|
|
557
557
|
intervals = np.arange(0, event_max + bin_width, bin_width)
|
|
558
558
|
|
|
559
|
-
event_table = event_table.groupby(pd.cut(event_table["event_at"], intervals, include_lowest=True)).agg(
|
|
559
|
+
event_table = event_table.groupby(pd.cut(event_table["event_at"], intervals, include_lowest=True), observed=False).agg(
|
|
560
560
|
{"removed": ["sum"], "observed": ["sum"], "censored": ["sum"], "at_risk": ["max"]}
|
|
561
561
|
)
|
|
562
562
|
# convert columns from multiindex
|
|
@@ -648,7 +648,7 @@ def datetimes_to_durations(
|
|
|
648
648
|
the units of time to use. See Pandas 'freq'. Default 'D' for days.
|
|
649
649
|
dayfirst: bool, optional (default=False)
|
|
650
650
|
see Pandas `to_datetime`
|
|
651
|
-
na_values : list, optional
|
|
651
|
+
na_values : list[str], optional
|
|
652
652
|
list of values to recognize as NA/NaN. Ex: ['', 'NaT']
|
|
653
653
|
format:
|
|
654
654
|
see Pandas `to_datetime`
|
|
@@ -679,7 +679,7 @@ def datetimes_to_durations(
|
|
|
679
679
|
start_times = pd.Series(start_times).copy()
|
|
680
680
|
end_times = pd.Series(end_times).copy()
|
|
681
681
|
|
|
682
|
-
C = ~(pd.isnull(end_times).values | end_times.isin(na_values or [""]))
|
|
682
|
+
C = ~(pd.isnull(end_times).values | end_times.astype(str).isin(na_values or [""]))
|
|
683
683
|
end_times[~C] = fill_date_
|
|
684
684
|
start_times_ = pd.to_datetime(start_times, dayfirst=dayfirst, format=format)
|
|
685
685
|
end_times_ = pd.to_datetime(end_times, dayfirst=dayfirst, errors="coerce", format=format)
|
|
@@ -1464,7 +1464,7 @@ def add_covariate_to_timeline(
|
|
|
1464
1464
|
cv = cv.sort_values([id_col, duration_col])
|
|
1465
1465
|
cvs = cv.pipe(remove_redundant_rows).pipe(transform_cv_to_long_format).groupby(id_col, sort=True)
|
|
1466
1466
|
|
|
1467
|
-
long_form_df = long_form_df.groupby(id_col, group_keys=False, sort=True).apply(expand, cvs=cvs)
|
|
1467
|
+
long_form_df = long_form_df.groupby(id_col, group_keys=False, sort=True)[long_form_df.columns].apply(expand, cvs=cvs)
|
|
1468
1468
|
return long_form_df.reset_index(drop=True)
|
|
1469
1469
|
|
|
1470
1470
|
|
|
@@ -1506,7 +1506,7 @@ def covariates_from_event_matrix(df, id_col) -> pd.DataFrame:
|
|
|
1506
1506
|
"""
|
|
1507
1507
|
df = df.set_index(id_col)
|
|
1508
1508
|
df = df.fillna(np.inf)
|
|
1509
|
-
df = df.stack(
|
|
1509
|
+
df = df.stack(future_stack=True).reset_index()
|
|
1510
1510
|
df.columns = [id_col, "event", "duration"]
|
|
1511
1511
|
df["_counter"] = 1
|
|
1512
1512
|
return (
|
lifelines/version.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: lifelines
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.30.0
|
|
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
|
|
@@ -16,13 +16,13 @@ Classifier: Topic :: Scientific/Engineering
|
|
|
16
16
|
Requires-Python: >=3.9
|
|
17
17
|
Description-Content-Type: text/markdown
|
|
18
18
|
License-File: LICENSE
|
|
19
|
-
Requires-Dist: numpy
|
|
20
|
-
Requires-Dist: scipy
|
|
21
|
-
Requires-Dist: pandas
|
|
22
|
-
Requires-Dist: matplotlib
|
|
23
|
-
Requires-Dist: autograd
|
|
24
|
-
Requires-Dist: autograd-gamma
|
|
25
|
-
Requires-Dist: formulaic
|
|
19
|
+
Requires-Dist: numpy>=1.14.0
|
|
20
|
+
Requires-Dist: scipy>=1.7.0
|
|
21
|
+
Requires-Dist: pandas>=2.1
|
|
22
|
+
Requires-Dist: matplotlib>=3.0
|
|
23
|
+
Requires-Dist: autograd>=1.5
|
|
24
|
+
Requires-Dist: autograd-gamma>=0.3
|
|
25
|
+
Requires-Dist: formulaic>=0.2.2
|
|
26
26
|
|
|
27
27
|

|
|
28
28
|
|
|
@@ -50,8 +50,8 @@ If you are new to survival analysis, wondering why it is useful, or are interest
|
|
|
50
50
|
|
|
51
51
|
## Contact
|
|
52
52
|
- Start a conversation in our [Discussions room](https://github.com/CamDavidsonPilon/lifelines/discussions).
|
|
53
|
-
- Some users have posted common questions at [stats.stackexchange.com](https://stats.stackexchange.com/search?tab=votes&q=%22lifelines%22%20is%3aquestion)
|
|
54
|
-
-
|
|
53
|
+
- Some users have posted common questions at [stats.stackexchange.com](https://stats.stackexchange.com/search?tab=votes&q=%22lifelines%22%20is%3aquestion).
|
|
54
|
+
- Creating an issue in the [Github repository](https://github.com/camdavidsonpilon/lifelines).
|
|
55
55
|
|
|
56
56
|
## Development
|
|
57
57
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
lifelines/__init__.py,sha256=F_sKrawq6L4GwTPgOu4FjoGUKQ2gfelAVIQOW1Ee8Ao,2241
|
|
2
2
|
lifelines/calibration.py,sha256=Luii7bkJ2YB0jpuOYYhI22aUyEc1gLsS10Pno6Sqo98,4113
|
|
3
3
|
lifelines/exceptions.py,sha256=8T1vQuI6Fnf_5OfiJahksn5Soe-SmU9Y2IA7HYen460,577
|
|
4
|
-
lifelines/generate_datasets.py,sha256=
|
|
4
|
+
lifelines/generate_datasets.py,sha256=nwGVpkcVRKH70N8z0Z-y7GgetX8suZZ1FFmdjOB8tBs,10188
|
|
5
5
|
lifelines/plotting.py,sha256=sQmwpSziHzVQoWoe_gll4LInrjg-E4FpeWMp07wurNo,35069
|
|
6
|
-
lifelines/statistics.py,sha256=
|
|
7
|
-
lifelines/version.py,sha256=
|
|
6
|
+
lifelines/statistics.py,sha256=dDLPz2FNZEI1PNkL9pfAfQToXSvrDgXdOxQsoluTw5o,35179
|
|
7
|
+
lifelines/version.py,sha256=fKPI8YV9Pdykklk91EAQOagw8PwkZHylDK82XMhvDjI,88
|
|
8
8
|
lifelines/datasets/CuZn-LeftCensoredDataset.csv,sha256=PxTdZcJPPbhtaadpHjhMFVcUxmSn84BuDarujZIJpm4,1996
|
|
9
|
-
lifelines/datasets/__init__.py,sha256=
|
|
9
|
+
lifelines/datasets/__init__.py,sha256=wiKbbNj-SSrgk_jysTdeQo1ceCmHXKje8WIzwBJAH_E,19977
|
|
10
10
|
lifelines/datasets/anderson.csv,sha256=nTAtTK8mf0ymU88nKvO2Fj0WL9SE9o4S0GVujmX8Cl4,580
|
|
11
11
|
lifelines/datasets/c_botulinum_lag_phase.csv,sha256=K3vda-75OqH-UxMAJIpYf0LldUZE5tiwch5ohP2v9Yw,386
|
|
12
12
|
lifelines/datasets/canadian_senators.csv,sha256=nbpDx6e_fLmalLaS9aeWC-2EIsE850XsOZTpN_OWqn0,163046
|
|
@@ -35,12 +35,12 @@ lifelines/datasets/rossi.csv,sha256=AhRAAXDgfzAVooXtyiAUysDa6KrBJfy6rWQkkOBfiSw,
|
|
|
35
35
|
lifelines/datasets/stanford_heart.csv,sha256=HWS9SqJjQ6gDmvxxKCJLR1cOIJ8XKuwTNu4bW8tKWVM,8859
|
|
36
36
|
lifelines/datasets/static_test.csv,sha256=w2PtSkXknCZfciwqcOZGlA8znBO7jTcq_AJ5e6NStAk,101
|
|
37
37
|
lifelines/datasets/waltons_dataset.csv,sha256=Fd4UX6tGYxgGhXtH3T-S81wIGIbVohv5yom4aw0kXL8,2449
|
|
38
|
-
lifelines/fitters/__init__.py,sha256=
|
|
39
|
-
lifelines/fitters/aalen_additive_fitter.py,sha256=
|
|
38
|
+
lifelines/fitters/__init__.py,sha256=a3ACmN8KANdg7uyZ36lSIMvUx0rZKB3HhvHdTgbQfP0,151648
|
|
39
|
+
lifelines/fitters/aalen_additive_fitter.py,sha256=xca1uoNbuPS2YoGQ73GYa5JLZTLCt9otJPhhi2AJm4A,21526
|
|
40
40
|
lifelines/fitters/aalen_johansen_fitter.py,sha256=w_2MV7Bbtr0swJ0VdySqirhlGsjbYyqduRx9iLKd6XA,14172
|
|
41
41
|
lifelines/fitters/breslow_fleming_harrington_fitter.py,sha256=_86qU3wMHEyuCKLjhHLERP_ymNnlSvi7chWgi8Kygxg,4293
|
|
42
|
-
lifelines/fitters/cox_time_varying_fitter.py,sha256=
|
|
43
|
-
lifelines/fitters/coxph_fitter.py,sha256=
|
|
42
|
+
lifelines/fitters/cox_time_varying_fitter.py,sha256=cZo9opn4OdFajrj6aBxJDhgWvFIUHdsq7jpgMQ0HchU,34670
|
|
43
|
+
lifelines/fitters/coxph_fitter.py,sha256=s4mWI1rj_kpsq2_kBa0Shg_FphBeIeJCEdW86aSFCls,137177
|
|
44
44
|
lifelines/fitters/crc_spline_fitter.py,sha256=FUaiz4O-Hdke7T5dV8RCl-27oWxrMJLBSXxnRN4QkGQ,3126
|
|
45
45
|
lifelines/fitters/exponential_fitter.py,sha256=Fbb1rtBOrHb_YxFYidzqXcFw7aWsqet_2vqi7s8WJ4U,2857
|
|
46
46
|
lifelines/fitters/generalized_gamma_fitter.py,sha256=OiXO9onvYtI2gNvUoxF4mjEjbj7IRZl5R4UZ_RzrSjo,6482
|
|
@@ -50,23 +50,23 @@ lifelines/fitters/log_logistic_aft_fitter.py,sha256=cw179z0_IqvuWgOORHSZ1lBiidHc
|
|
|
50
50
|
lifelines/fitters/log_logistic_fitter.py,sha256=iTH97i9TrLp5IVBIZHC8nx5rvSn2-KM-wfv1wR_YSPU,4004
|
|
51
51
|
lifelines/fitters/log_normal_aft_fitter.py,sha256=aOcdMR8T4vhy2BKGebrpEJD_lTZIQQ5VsrnuuKkU0RA,7890
|
|
52
52
|
lifelines/fitters/log_normal_fitter.py,sha256=NLn1DCxJ9WJrVaairJPcOu_lShko_-vwoXw6goRR42w,3557
|
|
53
|
-
lifelines/fitters/mixins.py,sha256=
|
|
53
|
+
lifelines/fitters/mixins.py,sha256=5s9FdxHUU0RxvFvmM77QmFiPmO7iyU7upzkF7BmWOec,12827
|
|
54
54
|
lifelines/fitters/mixture_cure_fitter.py,sha256=UetFlv9EfFYMDt95M2iR354lna5RKeWtO_lkoaMmoZE,5416
|
|
55
|
-
lifelines/fitters/nelson_aalen_fitter.py,sha256=
|
|
56
|
-
lifelines/fitters/npmle.py,sha256=
|
|
55
|
+
lifelines/fitters/nelson_aalen_fitter.py,sha256=C_hEuBwZfrYLbd6KNI34jEs-2B7Y3x2SIvp-HQGJW_Y,10687
|
|
56
|
+
lifelines/fitters/npmle.py,sha256=K2PX1YWuygzwUa5H6I2w6CF8uqELJqb1KJEiN5dZbRI,10157
|
|
57
57
|
lifelines/fitters/piecewise_exponential_fitter.py,sha256=j48sXaEODClFmfFP3THb0qJ3_Q7ctJz19j50Uo1QJME,3357
|
|
58
|
-
lifelines/fitters/piecewise_exponential_regression_fitter.py,sha256=
|
|
58
|
+
lifelines/fitters/piecewise_exponential_regression_fitter.py,sha256=kdnsm2oE1i_Sarxiw8lDcGEk8vachmNE8qCJdm3g_6U,4983
|
|
59
59
|
lifelines/fitters/spline_fitter.py,sha256=TnkXPBabgZVqtI90T1-gm6C8k73WhQMrhbEAZw1OX0c,4214
|
|
60
60
|
lifelines/fitters/weibull_aft_fitter.py,sha256=6wtU499AvXxZAE9PdnNQnbzh_NpPcdAEL6zd3xRV8hU,7772
|
|
61
61
|
lifelines/fitters/weibull_fitter.py,sha256=CcII_V5ns00jP5sqv0dn8Yo0T3kdyc4Rkpb2bBuTvjU,3771
|
|
62
|
-
lifelines/utils/__init__.py,sha256=
|
|
62
|
+
lifelines/utils/__init__.py,sha256=IIn6YTAh98n8Jb7y1MZcHlAcrmO5XiVcu2nMrfJVMbE,70500
|
|
63
63
|
lifelines/utils/btree.py,sha256=yevaIsGw_tQsGauXmwBHTMgCBjuuMZQgdHa-nCB-q2I,4369
|
|
64
64
|
lifelines/utils/concordance.py,sha256=hWXrmg1BiK2Hqu9CRzlvkPlnlmZqZcAxH7L1PjaqdC8,12245
|
|
65
65
|
lifelines/utils/lowess.py,sha256=MMydVcnbxqIgsiNcIgVUFtlFycD7v3ezwEGpituvBHs,2541
|
|
66
66
|
lifelines/utils/printer.py,sha256=-nXxu02gs0kaKfoQQ65sH-I45tGmgoFeOOIUSEc53iE,5861
|
|
67
67
|
lifelines/utils/safe_exp.py,sha256=HCCAkwQTx6G2qRC03v9Q_GWqVj8at1Eac1JVrMgS9hg,4350
|
|
68
|
-
lifelines-0.
|
|
69
|
-
lifelines-0.
|
|
70
|
-
lifelines-0.
|
|
71
|
-
lifelines-0.
|
|
72
|
-
lifelines-0.
|
|
68
|
+
lifelines-0.30.0.dist-info/LICENSE,sha256=AasDeD139SnTdfXbKgN4BMyMgBlRy9YFs60tNrB4wf0,1079
|
|
69
|
+
lifelines-0.30.0.dist-info/METADATA,sha256=KvpZHV7x8L87MWq3rkiDWekouWFvOp0dzUoPKHUfxk4,3175
|
|
70
|
+
lifelines-0.30.0.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
|
|
71
|
+
lifelines-0.30.0.dist-info/top_level.txt,sha256=3i57Z4mtpc6jWrsW0n-_o9Y7CpzytMTeLMPJBHYAo0o,10
|
|
72
|
+
lifelines-0.30.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|