关于 scala:found: org.apache.spark.sql.Dataset[(Double, Double)] 需要: org.apache.spark.rdd.RDD[(Double, Double)] | 珊瑚贝

found: org.apache.spark.sql.Dataset[(Double, Double)] required: org.apache.spark.rdd.RDD[(Double, Double)]


我收到以下错误

1
2
3
 found   : org.apache.spark.sql.Dataset[(Double, Double)]
 required: org.apache.spark.rdd.RDD[(Double, Double)]
    val testMetrics = new BinaryClassificationMetrics(testScoreAndLabel)

关于以下代码:

1
2
3
4
val testScoreAndLabel = testResults.
    select(“Label”,“ModelProbability”).
    map{ case Row(l:Double,p:Vector) => (p(1),l) }
val testMetrics = new BinaryClassificationMetrics(testScoreAndLabel)

从错误看来,testScoreAndLabel 是 sql.Dataset 类型,但 BinaryClassificationMetrics 需要 RDD。

如何将 sql.Dataset 转换为 RDD?


我会做这样的事情

1
2
3
val testScoreAndLabel = testResults.
    select(“Label”,“ModelProbability”).
    map{ case Row(l:Double,p:Vector) => (p(1),l) }

现在只需执行 testScoreAndLabel.rdd

即可将 testScoreAndLabel 转换为 RDD

1
val testMetrics = new BinaryClassificationMetrics(testScoreAndLabel.rdd)

API 文档


来源:https://www.codenong.com/40577904/

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_9173.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?