Machine Learning in Survival Analysis
Getting Started
by Raphael Sonabend and Andreas Bender
This book is a work in progress, the final work will be published by CRC Press. This electronic version (including PDF download) will always be free and open access (CC BY-NC-SA 4.0). We appreciate that you can enjoy this book for free online or buy the physical format and we hope you choose whichever is most convenient for you. Buying the book will be the greatest indicator to us that a second edition may be useful in the future.
We will strive to update this version after publication to correct mistakes (big and small), if you notice any mistakes please feel free to open an issue.
Licensing
This book is licensed under CC BY-NC-SA 4.0, so you can adapt and redistribute the contents however you like as long as you: i) do cite this book (information below); ii) do not use any material for commercial purposes; and iii) do use a CC BY-NC-SA 4.0 compatible license if you adapt the material.
If you have any questions about licensing, just open an issue and we will help you out.
Citation Information
Whilst this book remains a work in progress you can cite it as
Sonabend. R, Bender. A. (2026). Machine Learning in Survival Analysis.
https://www.mlsabook.com.
@book{MLSA2026,
title = {Machine Learning in Survival Analysis},
editor = {Raphael Sonabend, Andreas Bender},
url = {https://www.mlsabook.com},
year = {2026}
}
Contributing to this book
We welcome contributions to our book, whether you’re pointing out typos, requesting content, or even adding your own text. Major contributions (adding or reviewing content) will be acknowledged in the preface of the book.
Before you contribute, please read our code of conduct and then open an issue to discuss your proposed contribution.
Biographies
Dr. Raphael Sonabend-Friend is an Associate Director at the National Institute for Health and Care Excellence (NICE) and the CEO and Co-Founder of OSPO Now. Raphael holds a PhD focussed on the accessible and transparent use of machine learning for survival analysis. Raphael has over a decade of experience in the healthcare sector, including with large philanthropies, small local charities, governmental bodies, and private sector consulting for UK and international organisations. Raphael has created and maintained several software packages for survival analysis and machine learning, including mlr3proba, survivalmodels, and SurvivalAnalysis.jl. Raphael co-edited and co-authored Applied Machine Learning Using mlr3 in R (Bischl et al. 2024).
Dr. Andreas Bender is a Senior Lecturer at the Department of Statistics, Head of the Machine Learning Consulting Unit (MLCU) at the Munich Center for Machine Learning (MCML), LMU Munich, and founder of the Open Science Initiative in Statistics at LMU Munich. (Machine Learning) Survival Analysis is one of Andreas’ main research areas. Andreas created several open-source packages and actively contributes to survival-related software, including pammtools for piecewise exponential additive mixed models and mlr3proba for machine learning survival analysis.
Preface
Time-to-event data refers to data where the outcome of interest is defined by the time until an event occurs. This sort of data arises across almost all domains, from medicine and public health to engineering, economics, and finance. At first glance, analysis of time-to-event data might appear to be a standard regression problem with a non-negative outcome (as the time taken until an event must be positive). However, as stated by Dr. Terry Therneau, “it takes time to observe time” (Therneau 2024), which means that at the time of an analysis not all observations in the dataset will have experienced the event. Moreover, some observations will never experience the event, even outside of the observation window; for example being lost to follow-up (simply uncontactable) Instead of discarding these observations who do not experience the event, they are instead referred to as censored. Censoring is one defining feature of survival analysis and the reason it is mathematically distinct from standard regression or classification. Survival analysis makes full use of the censoring information by modelling for all observations: i) if the observation experienced the event or was censored; ii) the time until the event or censoring.
For illustration, consider two examples:
Stage IV lung cancer
In a five-year randomized trial of a new therapy for advanced non-small cell lung cancer, patients are observed from randomization into the study until the study end and it is recorded if a patient dies within the observation window. Those that die during the trial are said to have experienced the event of interest and their event time is fully observed. For the patients alive at the end of the trial, their survival time is censored at the end of the observation window. Practically speaking, they are said to have survived at least five years, but no further assumptions are made about their time of death.
A regression model trained only on the deaths would overestimate mortality and throw away information about the survivors. Alternatively, a regression model that treats deaths and censoring as equal would also overestimate mortality (though skewing towards study end if the treatment is successful). Survival analysis uses both groups in a single coherent model. Typical questions from a survival analysis include:
- What fraction of patients on the new therapy survive three years?
- How does mortality risk under the new therapy compare with the control arm?
- For a given patient, what is the probability of them being alive after two years?
Unemployment durations
In a study of the labour market, workers are followed throughout a period of individual unemployment. A worker may exit unemployment in several mutually exclusive ways: 1) into a full-time job; 2) into one or more part-time jobs; or 3) out of the labor force entirely; each exit may have very different determinants. Workers still unemployed (but in the labor force) at the end are censored. Later this setting will be introduced as competing risks and it introduces new challenges, such as adapting models to handle non-independent events. Despite this extra challenge, the questions of interest mirror the medical trial:
- How long until re-employment?
- Which workers are at greatest risk of long-term unemployment?
- What is the probability of re-employment within one year?
These two examples, medical and economic, share the structural features that motivate survival analysis, which also appears across component maintenance, credit risk, customer churn, and many more. Application-specific names (“reliability analysis” in engineering, “duration analysis” in economics) differ but the underlying mathematics is identical. Survival analysis has been developed over a long period to correctly handle partially observed (censored) data, which may be subject to (temporal) sampling bias (known as truncation) (Collett 2014; Kalbfleisch and Prentice 1980; Klein and Moeschberger 2003).
Scope
This book focuses entirely on predictive survival analysis (which we refer to simply as ‘survival analysis’), i.e. forward-looking predictions for new subjects. This is in contrast to inference methods, which examine model parameters to learn information about a given dataset or model. This book also does not cover using the discussed models to predict the remaining lifetime for in-sample censored observations. Bayesian and unsupervised methods are excluded as these remain nascent in the machine learning survival analysis setting; future editions will endeavour to include these methods. Predictive survival analysis is applied across a wide variety of industries, for example:
- Manufacturing: Predict the time to equipment failure;
- Pharmaceutical: Predict a patient’s survival trajectory after novel treatment;
- Healthcare: Predict a patient’s survival time after infection with meningitis;
- Finance: Predict the time until a customer defaults on a loan;
- Marketing: Predict the risk of a customer churning;
- E-commerce: Predict the time until next purchase for personalized marketing.
Despite its importance in many real-world settings, adaptation of machine learning in survival analysis has lagged behind predictive modeling for classification and regression. Partly this is due to the fact that analysis of time-to-event data is neither part of the canonical survival analysis or machine learning curriculum. The former often focuses on univariate, non-parametric techniques or simple linear models, traditionally due to sector-wide requirements for interpretability and uncertainty quantification (particularly in healthcare domains). Machine learning literature focuses on regression and classification which cover the majority of predictive use cases. In recent years there has been increasing overlap between survival analysis and machine learning, but in our experience there is still a substantial gap in the knowledge and skills required to combine the two fields. This books aims to further bridge the gap by introducing the key fundamental concepts of both fields before combining them to what we refer to as machine learning survival analysis.
The rapid rise of generative artificial intelligence (genAI) with tools such as ChatGPT, Gemini, and Claude, may lead readers to question the value of traditional machine learning methods. This is especially true in survival analysis where the slower adoption of machine learning means the field could leapfrog to genAI approaches. However, genAI is a sub-field of machine learning and the approaches in this book directly apply to newer methods. This is especially true for the underlying theory (Part I), evaluation (Part II) and reductions (Part IV). Moreover, when prompting genAI tools to solve a survival analysis problem, practically they almost always write code that leverages machine learning models, therefore understanding these models (Part II) is vital to ensure model explainability.
Overview of the book
This book is intended to fill a gap in the literature by providing a comprehensive introduction to machine learning in the survival setting. If you are interested in machine learning or survival analysis separately, then you might consider James et al. (2013); Hastie et al. (2001); or Bishop (2006) for machine learning and Collett (2014) or Kalbfleisch and Prentice (1980) for survival analysis. This book serves as a complement to the above works and introduces machine learning terminology from settings such as regression and classification, but without replicating the detail found in other sources. Instead, the primary focus is the intersection of the above two areas and defining the suitability of different methods and models depending on the available data. A particular aim is to introduce the different concepts and terminology necessary to correctly specify the machine learning survival analysis task. For example, before developing any models, it is necessary to identify the presence of different types of censoring and truncation as well as potentially competing risks and other complexities that could arise from time-to-event data. Failure to do so will lead to bias and potentially meaningless results.
This book may be useful for Master’s or PhD students who are specializing in machine learning in survival analysis, machine learning engineers looking to solve problems involving partially observed time-to-event data, or practitioners familiar with survival analysis but without machine learning knowledge. The book can be read cover-to-cover, but we believe it will also be useful as a reference book for you to dip into as required.
Following the introduction, this book is structured in four parts:
Part I: Machine Learning and Survival Analysis
Part I opens with a brief overview of machine learning, introducing key concepts that are universal to any application of machine learning, regardless of the specific setting. It then turns to the basic terminology and concepts of survival analysis, followed by more advanced concepts in the more general ‘event history analysis’ setting, which encompasses competing risks and multi-state models. This Part concludes by unifying terminology between machine learning and survival analysis to define what it means to have different survival prediction problems and a machine learning survival analysis task.
Part II: Evaluation
The second part of the book discusses model evaluation. Evaluation is crucial for choosing between models and eventually trusting the predictions from a trained machine learning model. Part II introduces measures for evaluating the different types of predictive task introduced in Part I. In each chapter, the measure class is introduced, specific metrics are listed, and commentary is provided on how and when to use the measures. Recommendations for choosing measures are discussed in the final chapter of the book. As this book focuses on the predictive setting, the evaluation measures introduced in Part II are all ‘out-of-sample’ measures, to be used for evaluating models on new, unseen data. This is in contrast to ‘in-sample’ measures, which evaluate how well a model is fit to data, and are usually preferred for inference tasks. Readers who are interested in in-sample measures are directed to Collett (2014) and Hosmer Jr et al. (2011) for discussion on residuals; Choodari-Oskooei et al. (2012) and Royston and Sauerbrei (2004) for \(R^2\) type measures; and Volinsky and Raftery (2000); Hurvich and Tsai (1989), and Liang and Zou (2008) for information criterion measures.
Part III: Models
Part III is a deep dive into models for solving survival analysis problems. This begins with ‘foundational survival’ models that may not be considered ‘machine learning’ by some; although, as will be shown, with a small level of tweaking, these models can be exceptionally powerful. This Part of the book continues by exploring different classes of machine learning models including random forests, support vector machines, gradient boosting machines, and neural networks. Whilst this book does not go into extensive detail about deep learning, the final chapter of this Part provides a foundation that can be complemented by works such as Goodfellow et al. (2016).
Each model class is introduced in classification or regression settings with extensions to survival analysis then discussed. Differences between model implementations are not discussed, that is, there is not extensive detail on whether one specific algorithm is superior to another. Instead, the focus is on understanding how these models are built for survival analysis. In this way, readers are well-equipped to independently follow papers that introduce specific implementations.
Part IV: Reduction Techniques
The final Part introduces reduction techniques, which are methods to transform survival tasks to more standard regression or classification tasks. Practitioners who are comfortable with machine learning in general but not necessarily survival analysis may find this Part of the book most useful for quickly implementing familiar models within the survival analysis domain.
The book’s final chapter provides our outlook on survival analysis and where we think the field may be heading.
Reproducibility
This book includes simulations and figures generated in \(\textsf{R}\), the code for any figures or experiments in this book are freely available at https://github.com/mlsa-book/MLSA under an MIT license.
Acknowledgments
We would like to gratefully acknowledge our colleagues who reviewed the content of this book, including: Lukas Burk, Dr. Cesaire Fouodo, Prof. Dr. Helmut Küchenhoff, Prof. Dr. Matthias Schmid, as well as all the anonymous reviewers who took the time to review and provide detailed feedback.
Parts of this book were reviewed and revised using generative AI tools. The authors fact-checked all responses and re-wrote any suggested text to ensure our own voice can be found throughout the book. We acknowledge the decades of literature that was scraped (legally or otherwise) by these tools.