-
Notifications
You must be signed in to change notification settings - Fork 15
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
Add Accuracy in time #75
base: main
Are you sure you want to change the base?
Conversation
acc_in_time = [] | ||
|
||
for tau in taus: | ||
mask_past_censored = (y_test["event"] == 0) & (y_test["duration"] < tau) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to be y_test["duration"] <= tau
in Eq 4 of the paper ?
y_pred_at_t = y_pred[:, :, tau_idx] | ||
y_pred_class = y_pred_at_t[~mask_past_censored, :].argmax(axis=1) | ||
|
||
y_test_class = y_test["event"] * (y_test["duration"] < tau) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
tau_idx = np.searchsorted(times, tau) | ||
y_pred_at_t = y_pred[:, :, tau_idx] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that okay if tau
does not belong to times
? It's probably fine if times
is sufficiently fine-grained. Perhaps we could interpolate.
from hazardous.utils import check_y_survival | ||
|
||
|
||
def accuracy_in_time(y_test, y_pred, times, quantiles=None, taus=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the docstring, the math formula as was done for Brier score would be very nice for the API doc (even if it looks kind of aweful in the docstring).
Address #74
Need to document and add test