Machine learning models · Phase 6 · Lesson 52

Survival analysis

Model time-to-event outcomes while handling censoring.

This is one focused step in the 60-lesson course. Use the retrieval check before moving on.

Lesson goal

Model time-to-event outcomes while handling censoring.

The core idea

Survival data records how long an event has not happened, but some observations end before the event is seen. Censoring is information, not an ordinary missing label.

Mental model

Picture it this way. Survival data records how long an event has not happened, but some observations end before the event is seen. Censoring is information, not an ordinary missing label. The important question is what assumption this picture makes, and whether that assumption fits the data.

Mathematical core

The survival function S(t) is the probability of surviving beyond t. The hazard describes instantaneous event risk conditional on surviving to t. The Cox model uses a proportional-hazards structure.

Worked example

A subscription company studies time to cancellation. A customer who is still active when the study ends contributes useful information up to that point but not a known cancellation time.

When to use it

It earns a place when

  • Use survival methods when the timing of an event and incomplete follow-up matter.
  • You can evaluate it against a credible baseline.
  • Its output fits the decision and data constraints.

Do not make it the default when

  • Do not treat censored cases as if they experienced the event at the censoring time or use ordinary regression without checking the event process.
  • A simpler model has not been tested.
  • The data or target definition is still unclear.

Failure modes

Watch for this. Non-proportional hazards, informative censoring, competing risks and changing treatment can violate a simple model.

When a result looks surprisingly good, inspect the split, target timing, error slices and data-generating process before celebrating.

Practice

Use this as a small experiment rather than a recipe to copy blindly. Change one thing, record the result and explain the change.

Do this. Create synthetic time-to-event data with right censoring. Fit a Kaplan-Meier curve and explain what the step changes mean.

Retrieval check

Answer from memory first. The buttons reveal feedback, but the durable step is explaining why.

1. What is right censoring?

2. What does the survival function describe?

3. Why can ordinary regression be wrong here?

Transfer prompt. Describe one real problem where this model or idea would be a sensible candidate. Name the target, the main risk and the metric you would inspect.

Primary source

Probabilistic Machine Learning. Use the source for the deeper treatment after you can explain the lesson's core idea without looking.