如何绘制两个密度分布之间的差异 [英] How to plot the difference between two density distributions

查看:61
本文介绍了如何绘制两个密度分布之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经训练了一个模型来预测某个变量.现在,当我使用该模型预测所述值并将该预测值与实际值进行比较时,我得到了以下两个分布.

I've trained a model to predict a certain variable. When I now use this model to predict said value and compare this predictions to the actual values, I get the two following distributions.

相应的R数据帧如下:

x_var | kind
3.532 | actual
4.676 | actual
...
3.12 | predicted
6.78 | predicted

这两个分布显然具有略微不同的均值,分位数等.我现在想做的是将这两个分布合并为一个(特别是因为它们非常相似),但是不是以下线程.

These two distributions obviously have slightly different means, quantiles, etc. What I would now like to do is combine these two distributions into one (especially as they are fairly similar), but not like in the following thread.

相反,我想绘制一个密度函数,该函数显示实际值和预测值之间的差异,并让我说出例如50%的预测在实际值的-X%和+ Y%之内.

Instead, I would like to plot one density function that shows the difference between the actual and predicted values and enables me to say e.g. 50% of the predictions are within -X% and +Y% of the actual values.

我尝试仅绘制 predicted-actual 之间的差异以及与各组中的平均值相比的差异.但是,两种方法都没有产生我想要的结果.使用绘制的分布图,尤其重要的是能够做出上述声明,即50%的预测都在实际值的-X%和+ Y%之内.如何实现?

I've tried just plotting the difference between predicted-actual and also the difference compared to the mean in the respective group. However, neither approach has produced my desired result. With the plotted distribution, it is especially important to be able to make above statement, i.e. 50% of the predictions are within -X% and +Y% of the actual values. How can this be achieved?

推荐答案

为更好地量化预测分布与实际分布之间的差异是否显着,您可以考虑使用R中的Kolmogorov-Smirnov检验,该检验可通过功能 ks.test

To better quantify whether the differences between your predicted and actual distributions are significant, you could consider using the Kolmogorov-Smirnov test in R, available via the function ks.test

这篇关于如何绘制两个密度分布之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆