首页 > 解决方案 > 具有加速失效时间的模型概率 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 

标签: pythonxgboostsurvival-analysis

解决方案


推荐阅读