comprisk:一个兼容scikit-learn的竞争风险生存分析Python工具包 comprisk: A scikit-learn-compatible Python toolkit for competing-risks survival analysis 预印本

⚠️ 本文为 预印本(arXiv 公开版本),尚未经过正式同行评审。作者自发公开,结论未经期刊审稿验证,阅读时请知悉。
发布时间:2026-07-10
⬇️ 4 次下载
👁️ 预览文献
💡 AI 中文简介
医学时间-事件数据常存在竞争风险,即多种互斥的终末事件(如死于心衰 vs 死于其他原因)中一种发生会阻止其他事件。若将竞争事件视为删失,标准生存分析会得到有偏的绝对风险估计。正确做法是估计病因特异性累积发生率函数(CIF)。此前这类方法几乎只在R包中实现,迫使Python用户不得不与R交互。我们开发了comprisk,一个兼容scikit-learn的Python工具包,将经典竞争风险方法整合到统一API中,包括可扩展的竞争风险随机生存森林、Fine-Gray子分布风险回归及其惩罚变体、病因特异性Cox回归、Aalen-Johansen CIF估计器、Gray K样本检验,以及考虑竞争风险的模型评估。所有估计器均与R参考实现进行数值验证。森林使用基于直方图、numba编译的分裂内核,在真实临床队列上拟合速度比randomForestSRC快10-22倍,判别性能相当,并可在消费级CPU上扩展到n=10^6。comprisk通过PyPI分发,让应用研究者无需离开Python科学栈即可进行正确、可扩展的竞争风险分析。
领域生物医学统计 / 生存分析
适合谁读需要一定专业背景(熟悉生存分析和Python)
核心贡献["提供统一的scikit-learn兼容API,整合多种竞争风险分析方法,避免Python与R的往返", "实现高性能的竞争风险随机生存森林,速度比R参考实现快10-22倍,可扩展到百万级样本"]
关键数据拟合速度比randomForestSRC快10-22倍,判别性能相当;可扩展到n=10^6(消费级CPU)
推荐理由如果你用Python做生存分析又不想碰R,这个工具包能让你轻松搞定竞争风险建模,而且速度飞快。
关键词["竞争风险", "生存分析", "累计发生率函数", "随机生存森林", "Fine-Gray模型", "scikit-learn"]

原文摘要

查看英文原文摘要

Medical time-to-event data are frequently subject to competing risks, where the occurrence of one terminal event precludes the others and standard survival methods that treat competing events as censoring yield biased absolute-risk estimates. Valid analysis instead targets the cause-specific cumulative incidence function (CIF). This methodology has been available to applied researchers almost exclusively through R packages, forcing Python-based machine-learning workflows into a Python-to-R round trip. We present comprisk, a scikit-learn-compatible Python toolkit that puts the canonical competing-risks methods behind one API: a scalable competing-risks random survival forest, Fine-Gray subdistribution-hazard regression and a penalized variant, cause-specific Cox regression, the Aalen-Johansen CIF estimator, and Gray's K-sample test, together with competing-risks-aware model evaluation. Every estimator is validated numerically against its R reference implementation. The forest uses a histogram-based, numba-compiled split kernel that fits 10-22x faster than randomForestSRC at comparable discrimination on real clinical cohorts and scales to n = 10^6 on a consumer CPU. comprisk is distributed on PyPI and lets applied researchers run correct, scalable competing-risks analysis without leaving the Python scientific stack.

📚 参考文献 (23 条)

查看23 条参考文献
  1. [1] Odd O. Aalen and Søren Johansen. An empirical transition matrix for non-homogeneous Markov chains based on censored observations. Scandinavian Journal of Statistics, 5(3):141–150, 1978.
  2. [2] Peter C. Austin, Douglas S. Lee, and Jason P. Fine. Introduction to the analysis of survival data in the presence of competing risks. Circulation, 133(6):601–609, 2016. doi: 10.1161/ CIRCULATIONAHA.115.017719.
  3. [3] Leo Breiman. Random forests. Machine Learning, 45(1):5–32, 2001. doi: 10.1023/A: 1010933404324.
  4. [4] Cameron Davidson-Pilon. lifelines: survival analysis in Python. Journal of Open Source Software, 4(40):1317, 2019. doi: 10.21105/joss.01317.
  5. [5] Jason P. Fine and Robert J. Gray. A proportional hazards model for the subdistribution of a competing risk. Journal of the American Statistical Association, 94(446):496–509, 1999. doi: 10.1080/01621459.1999.10474144.
  6. [6] Zhixuan Fu. crrp: Penalized Variable Selection in Competing Risks Regression, 2015. URL https://CRAN.R-project.org/package=crrp. R package version 1.0.
  7. [7] Thomas A. Gerds, Johan S. Ohlendorff, Paul Blanche, et al. riskRegression: Risk Regression Models and Prediction Scores for Survival Analysis with Competing Risks, 2026. URL https: //CRAN.R-project.org/package=riskRegression. R package version 2026.03.11.
  8. [8] Robert J. Gray. A class of K-sample tests for comparing the cumulative incidence of a competing risk. The Annals of Statistics, 16(3):1141–1154, 1988. doi: 10.1214/aos/1176350951.
  9. [9] Robert J. Gray. cmprsk: Subdistribution Analysis of Competing Risks, 2024. URL https: //CRAN.R-project.org/package=cmprsk. R package version 2.2-12.
  10. [10] Olivier Grisel, Vincent Maladière, Julie Alberge, Judith Abecassis, and Gaël Varoquaux. hazardous: Predictive Competing Risks and Survival Analysis, 2026. URL https://github. com/soda-inria/hazardous. Python package, version 0.2.0. 4
  11. [11] Hemant Ishwaran, Udaya B. Kogalur, Eugene H. Blackstone, and Michael S. Lauer. Random survival forests. The Annals of Applied Statistics, 2(3):841–860, 2008. doi: 10.1214/08-AOAS169.
  12. [12] Hemant Ishwaran, Thomas A. Gerds, Udaya B. Kogalur, Richard D. Moore, Stephen J. Gange, and Bryan M. Lau. Random survival forests for competing risks. Biostatistics, 15(4):757–773, 2014. doi: 10.1093/biostatistics/kxu010.
  13. [13] Mateusz Krzyziński, Mikołaj Spytek, Hubert Baniecki, and Przemysław Biecek. SurvSHAP(t): Time-dependent explanations of machine learning survival models. Knowledge-Based Systems, 262:110234, 2023. doi: 10.1016/j.knosys.2022.110234.
  14. [14] Håvard Kvamme, Ørnulf Borgan, and Ida Scheel. Time-to-event prediction with neural networks and Cox regression. Journal of Machine Learning Research, 20(129):1–30, 2019. URL http://jmlr.org/papers/v20/18-424.html.
  15. [15] Changhee Lee, William R. Zame, Jinsung Yoon, and Mihaela van der Schaar. DeepHit: A deep learning approach to survival analysis with competing risks. In Thirty-Second AAAI Conference on Artificial Intelligence, 2018.
  16. [16] Scott M. Lundberg, Gabriel Erion, Hugh Chen, Alex DeGrave, Jordan M. Prutkin, Bala Nair, Ronit Katz, Jonathan Himmelfarb, Nisha Bansal, and Su-In Lee. From local explanations to global understanding with explainable AI for trees. Nature Machine Intelligence, 2(1):56–67, 2020. doi: 10.1038/s42256-019-0138-9.
  17. [17] Sebastian Pölsterl. scikit-survival: A library for time-to-event analysis built on top of scikit- learn. Journal of Machine Learning Research, 21(212):1–6, 2020. URL http://jmlr.org/ papers/v21/20-729.html.
  18. [18] Hein Putter, Marta Fiocco, and Ronald B. Geskus. Tutorial in biostatistics: competing risks and multi-state models. Statistics in Medicine, 26(11):2389–2430, 2007. doi: 10.1002/sim.2712.
  19. [19] Skipper Seabold and Josef Perktold. statsmodels: Econometric and statistical modeling with python. In Proceedings of the 9th Python in Science Conference, 2010.
  20. [20] Terry M. Therneau. A Package for Survival Analysis in R, 2024. URL https://CRAN. R-project.org/package=survival. R package version 3.8-3.
  21. [21] Hajime Uno, Tianxi Cai, Michael J. Pencina, Ralph B. D’Agostino, and L. J. Wei. On the C-statistics for evaluating overall adequacy of risk prediction procedures with censored survival data. Statistics in Medicine, 30(10):1105–1117, 2011. doi: 10.1002/sim.4154.
  22. [22] Marcel Wolbers, Michael T. Koller, Jacqueline C. M. Witteman, and Michael Schemper. Prognostic models with competing risks: methods and application to coronary risk prediction. Epidemiology, 20(4):555–561, 2009. doi: 10.1097/EDE.0b013e3181a39056.
  23. [23] Marcel Wolbers, Paul Blanche, Michael T. Koller, Jacqueline C. M. Witteman, and Thomas A. Gerds. Concordance for prognostic models with competing risks. Biostatistics, 15(3):526–539, 2014. doi: 10.1093/biostatistics/kxt059. 5