需要一个使用Pandas DataFrame计算RMSE的简单示例。提供有功能,在循环真正的返回和预测值:Python Pandas:从数据帧计算RMSE的简单示例
def fun (data):
...
return trueVal, predVal
for data in set:
fun(data)
然后一些代码,使这些结果在下面的数据帧中x
是一个真正的价值和p
是一个预测值:
In [20]: d
Out[20]: {'p': [1, 10, 4, 5, 5], 'x': [1, 2, 3, 4, 5]}
In [21]: df = pd.DataFrame(d)
In [22]: df
Out[22]:
p x
0 1 1
1 10 2
2 4 3
3 5 4
4 5 5
问题:
1)如何把结果从fun
功能df
数据框?
2)如何使用df
数据框计算RMSE?
检查:http://stackoverflow.com/questions/17197492/root-mean- python中的平方误差 – MYGz
可能的重复[均方根误差i ((df.p - df.x)** 2)。(https://stackoverflow.com/questions/17197492/root-mean-square-error-in-python) –