scikit-survival
python
model interpretation
predict method
survival analysis

How to interpret output of .predict from fitted scikit-survival model in python?

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

In scikit-survival, .predict() usually does not mean "predicted survival time" and it often does not mean a direct survival probability either. For many fitted models, .predict() returns a risk score or linear predictor that is meaningful mainly for ranking samples relative to one another.

Start with the Model Type

The meaning of .predict() depends on the estimator. A common example is CoxPHSurvivalAnalysis, where .predict() returns the linear risk score.

A small example:

python
1import numpy as np
2from sksurv.datasets import load_whas500
3from sksurv.linear_model import CoxPHSurvivalAnalysis
4
5X, y = load_whas500()
6model = CoxPHSurvivalAnalysis().fit(X, y)
7
8scores = model.predict(X.iloc[:5])
9print(scores)

These numbers are not survival probabilities between 0 and 1. They are risk scores. Higher scores generally indicate higher hazard and therefore worse expected survival, relative to lower scores.

What a Risk Score Means

For Cox-style models, the prediction is fundamentally about ordering, not about a direct event time estimate. If patient A has a higher score than patient B, patient A is interpreted as higher risk under the fitted model.

That means .predict() is useful for:

  • ranking individuals by relative risk
  • comparing one sample against another
  • evaluation metrics such as concordance

It is not, by itself, the answer to questions like:

  • what is the survival probability at 2 years
  • what is the median survival time
  • will the event definitely happen before time t

Those require other prediction methods or further interpretation.

Use predict_survival_function for Survival Curves

If you want an estimated survival probability as a function of time, ask for the survival function explicitly.

python
1surv_funcs = model.predict_survival_function(X.iloc[:2])
2
3for fn in surv_funcs:
4    print(fn.x[:5])
5    print(fn.y[:5])

Each returned function represents estimated survival over time. Here:

  • 'fn.x contains time points'
  • 'fn.y contains survival probabilities at those times'

This is the right output when you need to say something like "the model estimates an 80 percent survival probability at a certain time point".

Use predict_cumulative_hazard_function for Hazard Accumulation

Another useful output is cumulative hazard.

python
1haz_funcs = model.predict_cumulative_hazard_function(X.iloc[:2])
2
3for fn in haz_funcs:
4    print(fn.x[:5])
5    print(fn.y[:5])

Cumulative hazard is not the same as survival probability, but it is closely related and often used in survival-analysis workflows.

The key interpretation difference is:

  • survival function decreases from near 1 downward
  • cumulative hazard increases over time

If you are seeing increasing curves, you may be looking at cumulative hazard rather than survival.

Do Not Confuse Relative Risk with Absolute Probability

This is the most common mistake. A risk score from .predict() might be negative, positive, larger than 1, or smaller than 0. That does not mean the prediction is broken. It means the output is not a probability scale.

For example, these are all possible and still valid as relative risk scores:

text
-1.3, 0.2, 2.1

The ordering matters more than the raw magnitude unless the model documentation gives a stronger interpretation.

Check the Estimator Documentation and API

Different scikit-survival estimators expose different prediction semantics. Before interpreting .predict(), verify whether the model returns:

  • linear predictor
  • risk score
  • cumulative hazard score
  • something estimator-specific

The safest workflow is:

  1. identify the estimator class
  2. inspect what .predict() is documented to return
  3. use predict_survival_function when you need time-dependent survival probabilities

That prevents a lot of misinterpretation.

Common Pitfalls

  • Treating .predict() output as a direct survival probability.
  • Assuming the result is a survival time estimate.
  • Comparing raw scores across unrelated models as if they were on the same calibrated scale.
  • Ignoring predict_survival_function when the actual question is about survival probability over time.
  • Forgetting that higher risk scores usually mean worse survival, not better survival.

Summary

  • In scikit-survival, .predict() often returns a relative risk score rather than a probability or time.
  • For Cox-type models, higher scores usually indicate higher hazard.
  • Use .predict() mainly for ranking and relative comparison.
  • Use predict_survival_function when you need survival probabilities across time.
  • Always interpret the prediction in the context of the specific estimator class.

Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.