我很困惑如何解释scikit生存模型中.predict
的输出。我已经通读了笔记本Intro to Survival Analysis in scikit-survival和API引用,但找不到解释。以下是导致我困惑的最简单的例子:
import pandas as pd
from sksurv.datasets import load_veterans_lung_cancer
from sksurv.linear_model import CoxnetSurvivalAnalysis
# load data
data_X, data_y = load_veterans_lung_cancer()
# one-hot-encode categorical columns in X
categorical_cols = ['Celltype', 'Prior_therapy', 'Treatment']
X = data_X.copy()
for c in categorical_cols:
dummy_matrix = pd.get_dummies(X[c], prefix=c, drop_first=False)
X = pd.concat([X, dummy_matrix], axis=1).drop(c, axis=1)
# display final X to fit Cox Elastic Net model on
del data_X
print(X.head(3))
下面是进入模型的X:
^{pr2}$…继续拟合模型并生成预测:
# Fit Model
coxnet = CoxnetSurvivalAnalysis()
coxnet.fit(X, data_y)
# What are these predictions?
preds = coxnet.predict(X)
preds
与X
具有相同数量的记录,但它们的值与data_y
中的值相差甚远,即使在相同的数据上进行预测时也是如此。在
print(preds.mean())
print(data_y['Survival_in_days'].mean())
输出:
-0.044114643249153422
121.62773722627738
那么preds
到底是什么呢?显然.predict
在这里的意思与scikit learn中有很大不同,但我不知道是什么意思。API Reference表示它返回“预测的决策函数”,但这意味着什么?对于给定的X
,我如何得到月yhat
的预测值?我是新来的生存分析,所以我显然遗漏了一些东西。在
我发布了这个问题on github,尽管作者重命名了这个问题。在
我得到了关于
predict
输出是什么的一些有用的解释,但是仍然不确定如何获得一组预测的生存时间,这正是我真正想要的。以下是github线程的一些有用的解释:-sebp(图书馆作者)
^{pr2}$-帕沃帕克斯。在
在github线程中有更多的解释,尽管我并不是真的能够理解所有的内容。我需要和
predict_survival_function
和predict_cumulative_hazard_function
一起玩,看看我是否能得到一组关于X
中最有可能存活时间的预测,这正是我真正想要的。在我不接受这个答案,以防其他人有更好的答案。在
使用X输入,可以得到输入数组的求值:
定义检查数组来自另一个library。 您可以查看coxnet的代码。在
相关问题 更多 >
编程相关推荐