【发布时间】:2017-05-20 09:39:04
【问题描述】:
我的实验室使用我们的 PI 所称的“改进的 Bland-Altman 图”来分析回归质量。我用 Seaborn 写的代码只处理离散数据,我想概括一下。
Bland–Altman plot 将两个度量之间的差异与其平均值进行比较。 “修改”是 x 轴是真实值,而不是平均值。 y 轴是预测值和真实值之间的差异。实际上,修改后的 B-A 图可以看作是来自 y=x 线的残差图——即行predicted=truth。
下面给出了生成此图的代码以及示例。
def modified_bland_altman_plot(predicted, truth):
predicted = np.asarray(predicted)
truth = np.asarray(truth, dtype=np.int) # np.int is a hack for stripplot
diff = predicted - truth
ax = sns.stripplot(truth, diff, jitter=True)
ax.set(xlabel='truth', ylabel='difference from truth', title="Modified Bland-Altman Plot")
# Plot a horizontal line at 0
ax.axhline(0, ls=":", c=".2")
return ax
诚然,这个例子的预测存在严重的偏差,如下降趋势所示。
我对两件事感到好奇:
- 这些“改良的 Bland-Altman 地块”是否有一个普遍接受的名称?
- 如何为非离散数据创建这些?我们使用
stripplot,它需要离散数据。我知道 seaborn 有residplot函数,但它没有为测量残差的线使用自定义函数,例如predicted=true。相反,它会根据计算出的最佳拟合线进行测量。
【问题讨论】:
标签: python matplotlib plot machine-learning seaborn