Skip to main content

Survival Analysis in Python

Use survival analysis to work with time-to-event data and predict survival time.

Start Course for Free
4 Hours16 Videos48 Exercises2,032 Learners
3850 XP

Create Your Free Account



By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA. You confirm you are at least 16 years old (13 if you are an authorized Classrooms user).

Loved by learners at thousands of companies

Course Description

How long does it take for flu symptoms to show after exposure? And what if you don't know when people caught the virus? Do salary and work-life balance influence the speed of employee turnover? Lots of real-life challenges require survival analysis to robustly estimate the time until an event to help us draw insights from time-to-event distributions. This course introduces you to the basic concepts of survival analysis. Through hands-on practice, you’ll learn how to compute, visualize, interpret, and compare survival curves using Kaplan-Meier, Weibull, and Cox PH models. By the end of this course, you’ll be able to model survival distributions, build pretty plots of survival curves, and even predict survival durations.

  1. 1

    Introduction to Survival Analysis


    What problems does survival analysis solve, and what is censorship? You’ll answer these questions as you explore survival analysis data, build survival curves, and make basic estimations of survival time.

    Play Chapter Now
    What is survival analysis?
    50 xp
    What problems does survival analysis solve?
    100 xp
    Choose the right data for survival analysis
    50 xp
    Why use survival analysis?
    50 xp
    Identify the censorship type
    50 xp
    Preprocess censored data
    100 xp
    First look at censored data
    100 xp
    Your first survival curve!
    50 xp
    Draw a survival curve
    100 xp
    Long live democracy!
    100 xp
  2. 2

    Survival Curve Estimation

    In this chapter, you’ll learn how the Kaplan-Meier model works and how to fit, visualize, and interpret it. You’ll then apply this model to explore how categorical variables affect survival and learn how to supplement your analysis using hypothesis testing methods like the log-rank test.

    Play Chapter Now
  3. 3

    The Weibull Model

    Discover how to model time-to-event data with parametric models. Learn how to use the Weibull model and the Weibull AFT model and what different purposes they serve. Use survival regression to make inferences about how covariates affect the survival function and learn how to select the best survival model for your data.

    Play Chapter Now
  4. 4

    The Cox PH Model

    Another chapter, another model! In this final chapter, you'll learn about the proportional hazards assumption and the role it plays in fitting and interpreting the Cox Proportional Hazards model. You’ll also learn how to predict new subjects' survival times using the Cox Proportional Hazards model.

    Play Chapter Now


Echocardiogram dataEmployee attrition dataRegimes dataPrison recidivism data


Maggie MatsuiHadrien Lacroix
Shae Wang Headshot

Shae Wang

Senior Data Scientist at Ripple

Shae Wang is a Senior Data Scientist at Ripple. She works on applied machine learning problems in the payments space, blockchain analytics, and experimentation. Before joining the blockchain industry, Shae was a Data Scientist at Uber and worked on a wide range of problems from OCR modeling and churn modeling to causal inference. Prior to her role at Uber, Shae used Neural Net to predict stock market movements for a startup. Shae earned her Masters in Computer Science with a focus in Machine Learning and Bachelor's degree in Statistics from Northwestern University.
See More

What do other learners have to say?

I've used other sites—Coursera, Udacity, things like that—but DataCamp's been the one that I've stuck with.

Devon Edwards Joseph
Lloyds Banking Group

DataCamp is the top resource I recommend for learning data science.

Louis Maiden
Harvard Business School

DataCamp is by far my favorite website to learn from.

Ronald Bowers
Decision Science Analytics, USAA