What is the x axis of the predict_survival_function() in Scikit Survival library

261 Views Asked by At

According to the docs
https://scikit-survival.readthedocs.io/en/stable/api/generated/sksurv.linear_model.CoxPHSurvivalAnalysis.html#sksurv.linear_model.CoxPHSurvivalAnalysis.predict_survival_function

it returns an array of probabilities of the survival function . When plotting this , which time frame is the x axis ?

There is a give plotting example on the docs page as below

for fn in surv_funcs:
    plt.step(fn.x, fn(fn.x), where="post")

plt.ylim(0, 1)
plt.show() 

What is does this part describe (plt.step(fn.x, fn(fn.x), where="post"))

1

There are 1 best solutions below

0
On
for fn in surv_funcs:
    plt.step(fn.x, fn(fn.x), where="post")

plt.ylim(0, 1)
plt.show() 

This works for CoxPH or any survival model that assumes PH . The return array from predict_survival_function() in CoxPH will be an array that has both X and Y values For Random forest use :

for i, s in enumerate(surv_funcs):
    plt.step(rsf_estimator.event_times_, s, where="post", label=str(i))
plt.ylabel("survival probabilities")
plt.xlabel("time")
plt.title("Predicted survival curve using Random Forest ")
plt.legend()
plt.grid(True)