Get startedGet started for free

Draw a survival curve

You are a sociologist studying how convicts behave after their release. The DataFrame prison contains the information from 432 convicts who were released from Maryland state prisons in the 1970s and who were followed up with one year after release. There are two main columns of interest:

  • week: the number of weeks elapsed since release
  • arrest: whether the convict has been re-arrested within one year after release

A Kaplan Meier survival function has been fitted for you and the model object is called prison_kmf. Can you visualize the survival curve of prison_kmf?

The matplotlib.pyplot library is imported as plt and the lifelines module has also been imported for you.

This exercise is part of the course

Survival Analysis in Python

View Course

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Plot the survival function
____

# Show the plot
____
Edit and Run Code