Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addressing issue #182 : scipy.integrate.simps deprecated #186

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions pycox/evaluation/ipcw.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def _inv_cens_score_single(func, ts, durations, events, surv, censor_surv, idx_t
g_ts = max(g_ts, min_g)
g_tt = max(g_tt, min_g)
score, w = func(ts, tt, s, g_ts, g_tt, d)
#w = min(w, max_weight)
# w = min(w, max_weight)
scores[i] = score * w
weights[i] = w

Expand All @@ -44,11 +44,14 @@ def metric(time_grid, durations, events, surv, censor_surv, index_surv, index_ce
n_indiv = len(durations)
scores = np.zeros((n_times, n_indiv))
weights = np.zeros((n_times, n_indiv))
idx_ts_surv = utils.idx_at_times(index_surv, time_grid, steps_surv, assert_sorted=True)
idx_ts_censor = utils.idx_at_times(index_censor, time_grid, steps_censor, assert_sorted=True)
idx_tt_censor = utils.idx_at_times(index_censor, durations, 'pre', assert_sorted=True)
idx_ts_surv = utils.idx_at_times(
index_surv, time_grid, steps_surv, assert_sorted=True)
idx_ts_censor = utils.idx_at_times(
index_censor, time_grid, steps_censor, assert_sorted=True)
idx_tt_censor = utils.idx_at_times(
index_censor, durations, 'pre', assert_sorted=True)
if steps_censor == 'post':
idx_tt_censor = (idx_tt_censor - 1).clip(0)
idx_tt_censor = (idx_tt_censor - 1).clip(0)
# This ensures that we get G(tt-)
_inv_cens_scores(func, time_grid, durations, events, surv, censor_surv, idx_ts_surv, idx_ts_censor,
idx_tt_censor, scores, weights, n_times, n_indiv, max_weight)
Expand Down Expand Up @@ -83,7 +86,7 @@ def metric(time_grid, durations, events, surv, censor_surv, index_surv, index_ce
max_weight=np.inf, steps_surv='post', steps_censor='post'):
scores = func(time_grid, durations, events, surv, censor_surv, index_surv, index_censor,
max_weight, True, steps_surv, steps_censor)
integral = scipy.integrate.simps(scores, time_grid)
integral = scipy.integrate.simpson(y=scores, x=time_grid)
return integral / (time_grid[-1] - time_grid[0])
return metric

Expand Down