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 exercício faz parte do curso
Survival Analysis in Python
Instruções do exercício
- 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.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# Plot partial effects
cph.____(covariates=____,
values=____)
# Show plot
plt.show()