Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 修改的Bland–;海伯恩的奥特曼阴谋_Python_Matplotlib_Plot_Machine Learning_Seaborn - Fatal编程技术网

Python 修改的Bland–;海伯恩的奥特曼阴谋

Python 修改的Bland–;海伯恩的奥特曼阴谋,python,matplotlib,plot,machine-learning,seaborn,Python,Matplotlib,Plot,Machine Learning,Seaborn,我的实验室使用PI所称的“修改的Bland–Altman图”来分析回归质量。我使用Seaborn编写的代码只处理离散数据,我想对其进行概括 A将两个度量值之间的差异与其平均值进行比较。“修改”是x轴是地面真值,而不是平均值。y轴是预测值和真实值之间的差值。实际上,修改后的B–A图可视为y=x线的残差图,即预测值=真值的线 下面给出了生成此图的代码以及一个示例 def modified_bland_altman_plot(predicted, truth): predicted = np

我的实验室使用PI所称的“修改的Bland–Altman图”来分析回归质量。我使用Seaborn编写的代码只处理离散数据,我想对其进行概括

A将两个度量值之间的差异与其平均值进行比较。“修改”是x轴是地面真值,而不是平均值。y轴是预测值和真实值之间的差值。实际上,修改后的B–A图可视为y=x线的残差图,即预测值=真值的线


下面给出了生成此图的代码以及一个示例

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

诚然,这个例子在预测中有着可怕的偏差,这一点可以从向下的斜率看出


我对两件事很好奇:

  • 这些“修改后的平淡-奥特曼情节”是否有一个公认的名称
  • 如何为非离散数据创建这些?我们使用
    条带图
    ,这需要离散数据。我知道seaborn有
    residplot
    函数,但它不为测量残差的行使用自定义函数,例如
    predicted=true
    。相反,它从计算的最佳拟合线进行测量

  • 您似乎在这里寻找标准散点图:


    您似乎在这里寻找标准散点图:


    颜色在上下文中表示什么?颜色在上下文中表示什么?
    import matplotlib.pyplot as plt
    import numpy as np; np.random.seed(1)
    
    
    def modified_bland_altman_plot(predicted, truth):
        predicted = np.asarray(predicted)
        truth = np.asarray(truth) 
        diff = predicted - truth
    
        fig, ax = plt.subplots()
        ax.scatter(truth, diff, s=9, c=truth, cmap="rainbow")
        ax.set_xlabel('truth')
        ax.set_ylabel('difference from truth')
        ax.set_title("Modified Bland-Altman Plot")
    
        # Plot a horizontal line at 0
        ax.axhline(0, ls=":", c=".2")
    
        return ax
    
    x = np.random.rayleigh(scale=10, size=201)
    y = np.random.normal(size=len(x))+10-x/10.
    
    modified_bland_altman_plot(y, x)
    
    plt.show()