ComenzarEmpieza gratis

Plot covariate effects on survival

Two convicts are on the waitlist to be released. You want to predict their survival function for time-to-arrest using the CoxPHFitter model you just fitted. The covariate values for the individuals are listed below:

Name fin age wexp mar paro prio
Jack 0 35 0 1 1 3
Marie 1 22 0 0 0 0

Plot Jack's and Marie's survival curves side-by-side with the baseline survival curve using cph. The fitted model cph has been loaded for you.

The CoxPHFitter class has been imported and the matplotlib.pyplot module has been imported as plt. The pandas and numpy libraries are imported as pd and np, respectively.

Este ejercicio forma parte del curso

Survival Analysis in Python

Ver curso

Instrucciones del ejercicio

  • Use .plot_partial_effects_on_outcome() to specify the covariate values (listed above) for Jack and Marie and plot their survival curves.
  • Show the plot.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# Plot partial effects
cph.____(covariates=____,
         values=____)

# Show plot
plt.show()
Editar y ejecutar código