From 8e8370d516be21dceacaf0a90575093b17c4f8a7 Mon Sep 17 00:00:00 2001 From: haavard Date: Mon, 2 Sep 2024 13:54:46 +0200 Subject: [PATCH] Fix items and monotonic increasing --- pycox/evaluation/eval_surv.py | 2 +- pycox/models/cox_time.py | 2 +- pycox/models/data.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pycox/evaluation/eval_surv.py b/pycox/evaluation/eval_surv.py index 5e16753..9ad5d8c 100644 --- a/pycox/evaluation/eval_surv.py +++ b/pycox/evaluation/eval_surv.py @@ -33,7 +33,7 @@ def __init__(self, surv, durations, events, censor_surv=None, censor_durations=N self.censor_surv = censor_surv self.censor_durations = censor_durations self.steps = steps - assert pd.Series(self.index_surv).is_monotonic + assert pd.Series(self.index_surv).is_monotonic_increasing @property def censor_surv(self): diff --git a/pycox/models/cox_time.py b/pycox/models/cox_time.py index 12b9cde..e663d67 100644 --- a/pycox/models/cox_time.py +++ b/pycox/models/cox_time.py @@ -94,7 +94,7 @@ def compute_expg_at_risk(ix, t): [self.duration_col] .loc[lambda x: x <= max_duration] .drop_duplicates(keep='first')) - at_risk_sum = (pd.Series([compute_expg_at_risk(ix, t) for ix, t in times.iteritems()], + at_risk_sum = (pd.Series([compute_expg_at_risk(ix, t) for ix, t in times.items()], index=times.values) .rename('at_risk_sum')) events = (df diff --git a/pycox/models/data.py b/pycox/models/data.py index a89b431..52fbafd 100644 --- a/pycox/models/data.py +++ b/pycox/models/data.py @@ -35,7 +35,7 @@ def make_at_risk_dict(durations): allidx = durations.index.values keys = durations.drop_duplicates(keep='first') at_risk_dict = dict() - for ix, t in keys.iteritems(): + for ix, t in keys.items(): at_risk_dict[t] = allidx[ix:] return at_risk_dict