前言:
今年在做的一个博士课题项目,主要是利用病人的数据,训练出一个AI模型,做因果分析,
以及个性化治疗。自己一直是做通讯+AI方向的,这个系列主要参考卡梅隆大学的教程,以及临床医生的角度 了解一下医学领域的相关背景,
参考 卡梅隆大学的 George 的【 Predicting Time-to-Event Outcomes - A Tour of Survival Analysis from Classical to Modern】
目录:
- Survail Aanalysis 简介
- 生存分析基本问题框架
- 传统回归模型解决此类问题
一 Survial Analysis 简介
预测事件发生时间,主要包括下面几类:
1: 死亡时间(本篇只讨论这个)
2: 疾病复发时间
3: 出院时间
4: 病情再次复发时间
5: 用户退订服务时间
Predicting time-to-event outcomes:
• Time until death Phrase terminology using this example
• Time until disease relapse
• Time until hospital discharge
• Time until a convicted criminal reoffends
• Time until a user unsubscribes from a service
本教程主要讨论下面几个事:
生存分析基本问题框架
经典估计方法与预测误差评估
机器学习界神经网络新进展
开放挑战与未来方向
二 生存分析基本问题框架
2.1 数据集说明
feaures | 中文翻译 |
---|---|
Gluten allergy | 麸质过敏 |
Immuno suppressant | 免疫抑制剂 |
Low resting heart rate | 静息心率过低 |
Irregular heart beat | 心律不齐 |
High BMI | 高身体质量指数 |
在预测病人生存期时候,通长会遇到病人还是活着的情况,这个时候6天要用大于等于6来替代
2.2 持续时间预测专用回归模型:
它的数据集标签跟一般的机器学习模型不一样,有两个:
标签1: 生存时间,
标签2: 死亡状态状态
2.3 例子
活着的例子
死亡的例子
2.4 生存曲线
生存曲线(Survival Curves)是生存分析(Survival Analysis)中的核心可视化工具,用于描述特定群体随时间推移的生存(或事件未发生)概率。以下是结构化解读:
基本定义
数学表达: S(t) = P(T > t)
表示个体存活时间T超过时间点t的概率,其中t≥0典型类型:
Kaplan-Meier曲线 (非参数估计,临床研究最常用)
Nelson-Aalen曲线 (累积风险函数估计)
参数模型曲线 (如指数分布/威布尔分布拟合)
2.4 生存曲线解读
正向事件 vs 负向事件
场景示例 | 时间延长含义 | 应用领域典型场景 |
---|---|---|
Time until death (死亡时间) |
"优"(生存期越长越好) | 癌症治疗评估、慢性病预后分析 |
Hospital length of stay (住院时长) |
"劣"(时间越长越差) | 医疗资源优化、医院运营效率评估 |
在给定的特征向量, 我们希望了解生存函数
2.5 理论基础 (Remarks on Theory)
总体而言,我们无法对所有时间点都任意精确地估计条件生存函数S(t | x)(即使在训练数据中,也存在最大观测时间!)。
典型的假设是:专注于在某个时间范围内估计S(t | x)
• 删失机制和删失率至关重要!当删失率较高时(例如40%以上),生存估计器的效果会显著下降 →预测硬盘故障时间、音乐人签约唱片公司时间等任务会变得非常困难
三 传统Linear regression 问题
预测回归模型,我们常用的是Linear Regression ,但是这里面存在一个问题。
当人是活着的,其生存时间是大于记录的时间。这个跟其它任务是不一样的。
针对该任务的特殊性,在模型的方向,自己也想到了一个创新的点,目前代码刚刚写完,预计本周会把结果做出来。
这边要感谢印度的 Mrutyunjaya Hiremath,做了回复
- Master of Technology
- Researcher at REVA University
You’re bringing up a very important issue. Predicting how long a patient will survive differs greatly from typical machine learning tasks like image recognition or binary classification. You’re right that using linear or logistic regression isn’t enough—these models don’t work well when survival time and censored data (patients still alive) are involved.
Better Models for Your Task
Since this is a survival prediction problem, here are some models that are more suitable and still offer good interpretability:
- Cox Proportional Hazards (CoxPH)
- A widely used model in medicine.
- It gives clear results like hazard ratios, which doctors can understand.
- Available in Python (lifelines) and R (survival).
- Random Survival Forests (RSF)
- A tree-based model that handles complex data and works well with censored information.
- You can still interpret which features are most important.
- DeepSurv
- A deep learning version of CoxPH that can capture more complex patterns.
- It is still interpretable using tools like SHAP.
- Paper link :
Article Deep Survival: A Deep Cox Proportional Hazards Network
- Code link : https://github.com/jaredleekatzman/DeepSurv
- Multi-task Logistic Regression (MTLR)
- Models survival over different time points.
- More flexible than Cox in some situations.
Better Metrics to Evaluate the Model
Standard metrics like AUC, R², or MSE are not the best fit for survival tasks. Instead, try these:
- C-index (Concordance Index): Checks how well the model ranks patients by survival time.
- Time-dependent AUC: AUC score that changes with time.
- Brier Score and Integrated Brier Score: Measure the accuracy of the model’s probability predictions over time.
These are made specifically for survival models and take censored data into account.
Try Some Early Plots
Before training models, you could try plotting Kaplan-Meier survival curves for groups like GCB vs. ABC or high vs. low KPS score. This can help show which features matter early on.
Useful Tools
- Python: scikit-survival, lifelines
- R: survival, survminer, randomForestSRC
- Deep Learning: DeepSurv GitHub link: https://github.com/jaredleekatzman/DeepSurv
Final Thoughts
In clinical settings, having a model that doctors can trust and understand is just as important as accuracy. You’ve raised a great question that applies to many medical AI projects.
教程: https://sites.google.com/view/survival-analysis-tutorial
代码: https://github.com/georgehc/dksa