- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试计算均方根对数误差,但我发现了几个选项,一种是使用 sklearn 指标:mean_squared_log_error 并取其平方根
np.sqrt(mean_squared_log_error( target, predicted_y ))
但我收到以下错误:
Mean Squared Logarithmic Error cannot be used when targets contain negative values
我还尝试了 Kaggle 帖子中的解决方案:
import math
#A function to calculate Root Mean Squared Logarithmic Error (RMSLE)
def rmsle(y, y_pred):
assert len(y) == len(y_pred)
terms_to_sum = [(math.log(y_pred[i] + 1) - math.log(y[i] + 1)) ** 2.0 for i,pred in enumerate(y_pred)]
return (sum(terms_to_sum) * (1.0/len(y))) ** 0.5
同样的问题,这次我收到域错误。
在同一篇文章中,他们对负面日志问题发表了以下评论:
You're right. You have to transform y_pred and y_test to make sure they don't carry negative values.
In my case, when predicting weather temperature (originally in Celsius degrees), the solution was to convert them to Kelvin degrees before calculating the RMSLE:
rmsle(data.temp_pred + 273.15, data.temp_real + 273.15)
是否有任何使用此指标的标准形式可以使用负值?
最佳答案
将两个数组标准化为 0 到 1 范围
如果您使用 scikit,则可以使用sklearn.preprocessing.minmax_scale
:
minmax_scale(arr, feature_range=(0,1))
在执行此操作之前,请保存 arr 的最大值和最小值。您可以取回实际值。
例如:
normalized = (value - arr.min()) / (arr.max() - arr.min()) # Illustration
关于python - 如何预处理数据来计算均方根对数误差?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57839824/
我想在 python 中找出一个整数的 log10,但我得到了一个错误,比如数学域错误 我的代码是这样的w=math.log10(q*q1)/math.log10(2) 其中 q1,q2 是整数 是的
舍入小数 在 NumPy 中,主要有五种方法来舍入小数: 截断 去除小数部分,并返回最接近零的浮点数。使用 trunc() 和 fix() 函数。 示例: import numpy as n
我有一个数值范围为 0 到 100 的 slider 。 我想将它们映射到 100 到 10,000,000 的范围内。 我在网上看到过一些函数,但它们都是用 C++ 编写的。我需要它在 Javasc
我想请用户输入一个整数(N),然后显示他/她输入的整数的 10 对数。我已经成功计算了 10 对数,但不知道如何像下面这样显示它: Write in an Integer: 455666 455666
我将 x 轴设置为对数刻度。最大值为10000,最小值为1。 GraphPane mypane = zedgraphcontrol.GraphPane; mypane.XAxis.Type = Axi
我正在尝试编写一个快速算法来计算 log gamma function 。目前我的实现看起来很幼稚,只是迭代了 1000 万次来计算 gamma 函数的对数(我还使用 numba 来优化代码)。 im
这个问题在这里已经有了答案: How to show minor tick labels on log-scale with Matplotlib (2 个答案) 关闭 7 年前。 将行 plt.y
抱歉标题不好 ;) 我正在尝试重新创建我在其他一些工作中遇到的 matlab 图,但我不太了解他们使用的比例。 y轴增量如下(从上往下[+ve y]): 0.9999,0.999,0.99,0.9,0
由于 1000 的以 10 为底的对数是 3,您可能期望 Math::log(1000, 10) 返回 3。相反,它返回 2.9999999999999996。 这是因为 Ruby 中的 float
我对对数 X 轴有疑问。阈值大于 0,x 的最小值为 1,并且所有 X 值都大于 0。并且仍然给我相同的错误 Can't plot zero or subzero values on a logari
我需要在我的应用程序中实现折线图,我想使用 MPAndroidChart。问题是 y 轴上的值将介于 1 和 1x10^-12 之间。这就是为什么我需要在该轴上的对数 View 。 有没有办法用那个库
我正在尝试按照 Logarithmic slider 中的示例进行操作. 这是我使用的代码: Timeline._MIN_PER_MINUTE = 1; Timeline._MIN_PER_HOUR
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 9 年前。 Improve th
我尝试为对数 y 轴绘制条形图。不幸的是,如果我将 y 轴设置为对数,则不再有条形图。我该怎么做才能实现这一目标?是否可以在 bar-function 中设置引用点(默认似乎为零)? 我的代码是: i
所以我一直在努力掌握 Big Oh 的计算方法。我觉得我已经掌握了基础知识,但对看似非常简单的计算感到困惑。所以如果下面的计算有很大的 O(n log n)(我真的希望我至少做对了)改变循环的顺序对复
我知道二维绘图的 semilogx 和 semilogy。 SURF 和 MESH 有什么等价物吗? 最佳答案 如上述链接所述,要将所有三个轴设置为对数刻度,请使用 set(gca, 'XScale'
这看起来很简单,但我在用 Ruby 计算 log (Base 5) 时遇到了问题。 显然标准的 base-10 日志工作正常: >> value = Math::log(234504) => 12.3
这段代码是用 C 语言根据 pollard 的对数 rho 算法(来自 wiki)编写的。在此代码中,如果我输入 alpha=2、beta=5、N=1019,则必须返回 a=681、b=378、A=3
有了this question之后通过指向 an external site 的链接回答,我意识到我解决了一个问题,只是为了得到另一个问题:在对数刻度上,MESH 和 SURF 函数的 C=Z 参数不
我正在尝试解决 the SPOJ problem PGCD , 它询问最大公约数表中出现了多少个素数。 我想到的第一个想法是先通过筛分生成素数。 然后,对于每个素数 p,查看有多少对(a,b),其中
我是一名优秀的程序员,十分优秀!