CommencerCommencer gratuitement

Plotting and comparing survival curves

Back at the heart clinic, you want to present some visualizations that showcase the differences in patient survival times to the Head of Research. You will plot the survival curves of patients with and without pericardial effusion side-by-side.

A KaplanMeierFitter object kmf is instantiated. DataFrames for patients with and without pericardial effusion are loaded and stored as has_pericardial_effusion and none_pericardial_effusion, respectively.

The KaplanMeierFitter class is imported for you. Additionally, the pandas package is loaded as pd, and the matplotlib.pyplot module is loaded as plt.

Cet exercice fait partie du cours

Survival Analysis in Python

Afficher le cours

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Fit kmf to patients with pericardial effusion
____.____(____, ____, label='has_pericardial_effusion')

# Create a plot of the survival function
surv_plot = kmf.____()
Modifier et exécuter le code