python - 具有加速失效时间的模型概率 XGBoost 生存分析
问题描述
我创建了一个 XGboost Accelerated Failure Time 模型,代码如下,它输出数据集中每个人的估计生存时间。有没有办法输出一系列不同时间点的生存概率。文档对此相当稀疏。我已经使用 XGBSE 包以稍微不同的模型格式创建概率,但我也想使用基本包来创建概率。
https://xgboost.readthedocs.io/en/latest/tutorials/aft_survival_analysis.html
代码片段在这里
PARAMS_XGB_AFT = {
'objective': 'survival:aft',
'eval_metric': 'aft-nloglik',
'aft_loss_distribution': 'normal',
'aft_loss_distribution_scale': 1.5,
'tree_method': 'hist',
'learning_rate': 5e-2,
'max_depth': 8,
'booster':'dart',
'subsample':0.5,
'min_child_weight': 50,
'colsample_bynode':0.5
}
# training model
bst = xgb.train(
PARAMS_XGB_AFT,
dtrain,
num_boost_round=1000,
early_stopping_rounds=10,
evals=[(dval, 'val')],
verbose_eval=0
)
# predicting and evaluating
preds = bst.predict(dval)
cind = concordance_index(y_valid, -preds, risk_strategy='precomputed')
print(f"C-index: {cind:.3f}")
# outputs the estimated survival time for each individual in data set
preds
解决方案
推荐阅读
- javascript - 检查数组中的值是否为真,并在打字稿中返回这些值的索引
- php - 位置块根被 nginx 上的服务器根定义覆盖
- c++ - 如何在 CodeBlocks (C++) 中将 libcurl 链接为静态库
- javascript - 徽标图像未显示在标题中
- function - 从函数和“闭包”构造“词法环境”的操作顺序是什么?
- hive - 通过在 hive 中使用 case 语句向薪水列添加额外金额
- bevy - 如何在 Bevy 系统中进行嵌套查询?
- python - 我如何实时像素化来自opencv视频捕获的图像
- django-3.0 - 使用 Django 从 HTML 获取解析的好格式是什么
- python - 表单验证错误未显示在 Django 的 HTML 页面中