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.
Cet exercice fait partie du cours
Survival Analysis in Python
Instructions
- 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.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Plot partial effects
cph.____(covariates=____,
values=____)
# Show plot
plt.show()