I want to implement concordance_index_censored on my test set, using the model I trained.
I don't understand which should be my input into the estimate
parameter in concordance_index_censored()
.
Is it somewhere in coxnet_pred? If not, where should I get it from? I tried coxnet_pred['array'] and that doesn't work because it contains step functions.
Code as follows
from sksurv.linear_model import CoxnetSurvivalAnalysis
from sksurv.metrics import concordance_index_censored
from sksurv.util import Surv
y=Surv.from_arrays(np.array(survival_status_training), np.array(survival_time_training), name_event="event",name_time ="time")
cox_lasso_model = CoxnetSurvivalAnalysis(l1_ratio=1.0, fit_baseline_model=True)
cox_lasso_trained = cox_lasso_model.fit(training_data, y)
coxnet_pred=cox_lasso_trained.predict_survival_function(np.array(test_data))
training_cindex = concordance_index_censored(event_indicator=np.array(survival_status_training),event_time=np.array(survival_time_training), estimate=coxnet_pred['array'])
The
estimate
parameter forconcordance_index_censored
should be an array with a single risk score per instance in your test data:Alternatively, you can use
model.score(test_X, test_y)
as explained in the user guide.