简体   繁体   English

从 PySpark 中的两个不同数据框中减去列的值以找到 RMSE

[英]Subtract values of columns from two different data frames in PySpark to find RMSE

I am not able to figure it out.我无法弄清楚。 I am trying to calculate the RMSE between test and prediction data.我正在尝试计算测试和预测数据之间的 RMSE。

test测试

col1    col2
 a        2 
 b        3

prediction预言

col1   col2
 a       4 
 b       5

I am trying to do this test(col2)-prediction(col2).我正在尝试做这个测试(col2)-预测(col2)。 That is那是

2-4 =-2
3-5 =-2

I tried我试过

test.select("col2").subtract(prediction.select("col2"))

But I am not getting the required result.但我没有得到所需的结果。 I am trying to obtain this result to find the RMSE.我试图获得这个结果来找到 RMSE。 Is there a built in function in spark to find the RMSE? spark中是否有内置函数来查找RMSE?

Thank you.谢谢你。

它是一个连接和一个算术减法:

test.join(prediction, on="col1").withColumn("sub", test.col2-prediction.col2)

请在以下表达式中替换您的表名:

tab1.join(tab2).withColumn("Sub", tab2("T1")-tab1("T")).select("Sub").show() 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM