Articles
Survival Analysis Interview Questions: Censoring, Kaplan-Meier, and Model Evaluation
Practice survival analysis interview questions with a six-user Kaplan–Meier example, censoring pitfalls, hazard interpretation, and model evaluation checks.
Survival analysis interview questions test whether you can reason about outcomes that have not all had time to occur. Start by defining the event, the time origin, and when observation ends. A subscriber who is still active when your dataset closes is not a confirmed lifetime non-churner, and deleting that subscriber discards useful information.
For applied data science interviews, a strong answer connects this observation problem to a calculation and an evaluation decision. This guide uses six fictional subscribers, a worked Kaplan–Meier estimate, and two prediction vectors with identical ordering but different probability errors. The examples are original practice material; package behavior and definitions are grounded in the linked official documentation.
Define the Event Before Choosing the Model
Survival analysis studies the time until a specified event while accounting for incomplete observation. The survival function, S(t) = P(T > t), gives the probability that the event has not happened by time t. “Survival” can mean remaining subscribed, avoiding a machine failure, or continuing to wait; it is not limited to medical outcomes. lifelines univariate models
Our fictional event is the first completed subscription cancellation after activation. Time zero is activation, measured in elapsed days. A cancellation request that is later withdrawn is not an event under this particular contract. A reactivation does not undo a first-cancellation event; modeling repeated exits and returns would require a different question.
Before calculating anything, ask whether the business wants time to first cancellation, probability of being active on a date, or recurrent subscription behavior. These can produce different labels from the same activity logs. A model cannot repair an ambiguous event definition.
What Does Right-Censoring Tell You?
Right-censoring means you know the event time exceeds an observed duration, but not the eventual event time. In our example, later subscribers have shorter follow-up because the extract closes on a fixed calendar date. Everyone enters the analysis at activation; there is no delayed entry in this fixture.
A basic Kaplan–Meier interpretation depends on a suitable independent or non-informative censoring assumption. If people disappear from observation specifically because they are about to cancel, treating their disappearance as ordinary administrative censoring can bias the result. The observation process deserves the same attention as the prediction model. lifelines guidance
For this practice dataset, assume follow-up ends administratively and that the pooled subscribers are comparable for estimating the curve. In actual product data, signup period, acquisition channel, and product changes may make that pooling questionable. State what you checked instead of assuming all extracts satisfy the same conditions.
Work Through Six Subscriber Records
The following data are invented. “End day” is measured from each subscriber's activation, not a shared calendar date. Event equals one for observed cancellation and zero for censoring.
| User | End day | Event |
|---|---|---|
| A | 2 | 1 |
| B | 3 | 0 |
| C | 4 | 1 |
| D | 4 | 0 |
| E | 6 | 1 |
| F | 8 | 0 |
The Kaplan–Meier calculation multiplies conditional survival factors at event times: S(t) = product(1 - d_j / n_j). Here n_j is the number still at risk immediately before the event time, and d_j is the number of events at that time.
At day 2, all six subscribers are at risk and A cancels. The estimate becomes 1 × (1 - 1/6) = 5/6, approximately 0.8333. B remains informative until day 3, when observation ends. That censoring does not create a downward step in the survival estimate.
At day 4, C, D, E, and F are still at risk. We use the standard event-before-censoring convention for events and censoring recorded at the same time. C's cancellation therefore uses a risk set of four; D is removed afterward. The estimate becomes (5/6) × (1 - 1/4) = 5/8, or 0.625.
At day 6, E and F remain. E cancels, giving (5/8) × (1 - 1/2) = 5/16, or 0.3125. F's censoring at day 8 leaves the estimate unchanged. It does not establish that F will never cancel.
The ties require care because coarse daily timestamps may hide within-day order. State the convention, inspect the available timestamp resolution, and avoid claiming an exact intraday sequence that the source data cannot reveal.
Why Deleting Censored Users Changes the Question
If you remove B, D, and F before fitting, you retain only the three observed cancellations. At day 4, two of those three users have cancelled, leaving a survival estimate of one-third. The correct fixture calculation gave 0.625.
This is not an alternative estimator of the same cohort with harmless missing rows. You selected users based on whether their event was observed. You removed people who contributed valid time at risk and changed the population being summarized.
The opposite shortcut also fails: assigning every censored person a permanent non-event label pretends to know their unobserved future. For a fixed-horizon classification problem, you need to establish whether each person's outcome at that horizon is known, or use a method that addresses the missing follow-up appropriately.
Notice how the original example separates two mistakes. B contributes to the day-2 denominator even though B is later censored. At day 4, B no longer contributes because observation ended earlier. Keeping everyone in every denominator is not the same as handling censoring correctly.
Reproduce the Calculation in Python
We executed the following calculation locally with lifelines 0.30.3. The event table confirmed risk sets of six, four, and two at days 2, 4, and 6. Numerical assertions matched the hand calculation.
from lifelines import KaplanMeierFitter
durations = [2, 3, 4, 4, 6, 8]
events = [1, 0, 1, 0, 1, 0]
km = KaplanMeierFitter().fit(durations, events)
print(km.predict([2, 4, 6]).round(4).tolist())
# [0.8333, 0.6250, 0.3125]
print(km.event_table)
This is a six-record arithmetic exercise, not a statistically credible estimate for a business population. A real report should include uncertainty and the number still at risk. A flat tail supported by one observed person deserves a different interpretation from a stable estimate supported by thousands.
If asked for a median in this fixture, identify where the estimated survival curve first reaches or falls below one-half: day 6. If a different curve never crosses one-half during observed follow-up, do not manufacture a median by extending the last horizontal segment indefinitely.
Explain Hazard Without Calling It a Probability
A hazard describes the event rate at a time conditional on remaining event-free until then. In a continuous-time model, it is not itself the probability of cancellation by a deadline. A hazard ratio compares such rates between covariate profiles; it is not a ratio of cumulative cancellation probabilities.
The Cox proportional hazards model expresses a baseline hazard multiplied by a covariate-dependent factor. Under its proportional-hazards assumption, that factor does not change with time for fixed covariates. Survival probabilities also depend on the baseline cumulative hazard. lifelines survival regression
For an original numerical illustration, suppose one profile has twice another's hazard and the baseline survival probability at a particular horizon is 0.8. Under this model, the other profile's survival probability is 0.8² = 0.64. Event probabilities are therefore 0.2 and 0.36, not 0.2 and 0.4.
In an interview, explain what would make the proportional relationship questionable: an effect concentrated during onboarding may weaken later. Describe checking assumptions and considering time-varying effects or another appropriate model. Do not treat a fitted coefficient as causal evidence of what would happen if you changed a customer's feature.
Can Equal Rankings Have Different Probability Accuracy?
Yes. Consider two arbitrary prediction vectors, not fitted models, for surviving beyond day 2. In user order A through F:
Vector A: 0.20, 0.70, 0.75, 0.80, 0.85, 0.90
Vector B: 0.80, 0.90, 0.91, 0.92, 0.93, 0.94
Observed: 0, 1, 1, 1, 1, 1
All six day-2 outcomes are known because the earliest censoring occurs on day 3. A cancels at day 2, so T > 2 is false for A. Both vectors rank the users identically, but B assigns much more survival probability to the user who cancels.
The ordinary Brier score here is the average squared difference between the probability and the observed survival indicator. Local NumPy calculations returned approximately 0.04417 for A and 0.11217 for B. Lower is better for this loss. Identical ordering plainly did not imply identical probability accuracy.
This tiny example does not establish population calibration or model superiority. It demonstrates why a ranking-only comparison cannot answer a probability-quality question. At a later horizon, some labels become unknown because of censoring, and this unweighted calculation would no longer be justified for all six records.
Choose Evaluation Metrics for the Decision
Concordance evaluates ordering among usable comparisons; it does not certify calibrated survival probabilities. Cumulative/dynamic AUC evaluates discrimination at a chosen horizon, comparing events by that time with people still event-free. The Brier score evaluates probability error, reflecting both discrimination and calibration. An integrated Brier score summarizes error over a specified time range. scikit-survival evaluation guide
Match the metric to the requested output. A prioritized investigation queue needs useful ranking. A forecast of expected cancellations at day 30 also requires meaningful probabilities. A model can perform well on one objective and poorly on another.
For censored outcomes, inverse probability of censoring weighting, or IPCW, compensates for the observation process under its assumptions. The scikit-survival Brier API estimates censoring from training survival data and requires appropriate follow-up support; it expects survival probabilities, not arbitrary risk scores. Unsupported evaluation times can fail or make the intended estimate unreliable. Brier score API
Specify evaluation horizons before comparing models. Fit preprocessing on training data, keep the held-out population consistent, and inspect whether enough people remain observable at each horizon. Do not improve a headline metric by quietly dropping the hardest time points after seeing results.
Practice the Assumptions, Not Just the Formula
A competing event needs its own interpretation. If a separate event prevents the cancellation outcome you defined, automatically treating it as independent censoring can change the estimand. Explain whether you want a cause-specific rate, overall event-free survival, or a cumulative incidence accounting for competing outcomes.
| Question | Practice focus |
|---|---|
| Model waiting-time abandonment via survival | Revisit the observation process for a different event |
| Build Churn Prediction and Survival Models | Choose a time-to-event formulation |
| Predict and act on contract renewal risk | Connect horizons and predictions to decisions |
| Explain bias-variance, calibration, and model drift | Separate probability quality from ordering |
| Evaluate a model and choose metrics | Defend what your evaluation measures |
Start with the waiting-time exercise and explicitly name one circumstance where censoring might be informative. That is the bridge from calculating a curve to defending an analysis.
Sources and Further Reading
- lifelines: Estimating univariate models
- lifelines: Survival regression
- scikit-survival: Evaluating survival models
- scikit-survival: Brier score API and support requirements
Checked September 10, 2026. All subscriber data and prediction vectors are original fictional examples; the stated arithmetic was executed locally.