-
Notifications
You must be signed in to change notification settings - Fork 75
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
AssertionError: Times should be within the range of event times to avoid exterpolation #138
Comments
Hi @rvandewater, thanks for contributing to auton-survival 🙂 Given a min_time = min(Y_train.times.values) + 1
max_time = max(Y_train.times.values) - 1 To avoid this problem you have three options:
from sksurv import metrics
from auton_survival import DeepCoxPH
import torch
model = DeepCoxPH()
# ... train model ...
# Use model.torch_model[0] to access the `torch.nn.Module` that computes risk scores for DeepCox
# A better (and retro-compatible) API to access the PyTorch module will be available in the next updates
with torch.inference_mode():
model.torch_model[0].eval()
X_test, Y_test = get_test_data()
risk_scores = model.torch_model[0](X_test)
concordance_index_censored = metrics.concordance_index_censored(
Y_test.events.values.astype(bool),
Y_test.times.values,
risk_scores.squeeze(),
) I'm not sure if this satisfies your question, let me know if you need anything else NB: I'm copying your code with syntax highlighting so it's easier to read (you can enable it by writing "```python" instead of " ```" at the start of the code block):
|
Hi @matteo4diani, thanks for your answer. I believe the manual cutting-off that you suggested was not even needed, but I replaced this line: times = np.quantile(y_tr['time'][y_tr['event']==1], np.linspace(0.1, 1, 10)).tolist() With this line: times = np.quantile(y_val['time'][y_val['event']==1], np.linspace(0.1, 1, 10)).tolist() The training data quantiles are validated within the code. I am not sure if this is intended like this as according to https://autonlab.org/auton-survival/metrics.html this should probably be based on the validation or test set and not the training set: times : np.array |
Hi,
Thank you for creating this package.
I am encountering an error when using my own dataset for creating a survival regression model (see below). I am using the
Survival Regression with Auton-Survival
notebook with the cox proportional hazards model (see code below error). I am using a preprocessed dataset extracted from eICU with the max time value 168 for train, test, and val.What I tried: when I try to replace the 168 in validation to 167 it gives me the same error. I checked the original example, and there seems to be the same situation that the max value in validation is equal to the same value in training; however, it does not throw an error here.
Thank you for your help.
The text was updated successfully, but these errors were encountered: