[英]value _1 is not a member of org.apache.spark.mllib.recommendation.Rating
I have an application with spark MLlib-scala, I want to split my data on 3 parties: Training, test, validation. 我有一个带有spark MLlib-scala的应用程序,我想将数据分为3个方面:培训,测试,验证。 My code is the following: 我的代码如下:
val training_RDD = Ratingfiles.filter(x => x._1 < 6)
.values
.cache()
val validation_RDD = Ratingfiles.filter(x => x._1 >= 6 && x._1 < 8)
.values
.cache()
when I compile my program with sbt compile, I have this error: 当我使用sbt compile编译程序时,出现以下错误:
value _1 is not a member of org.apache.spark.mllib.recommendation.Rating
Spark-core: 1.4.1 Spark-MLlib:2.0.1 Scala version: 2.11.1 Sbt version: 0.13.12 Spark-core:1.4.1 Spark-MLlib:2.0.1 Scala版本:2.11.1 Sbt版本:0.13.12
As the compiler claims, org.apache.spark.mllib.recommendation.Rating
does not have a member called _1
(you're probably confusing it with a Tuple, for which the members are _1
, _2
etc.). 正如编译器所声称的那样, org.apache.spark.mllib.recommendation.Rating
没有名为_1
的成员(您可能将其与Tuple混淆,其成员为_1
, _2
等)。
Rating
has three members: Rating
由三名成员组成:
case class Rating @Since("0.8.0") (
@Since("0.8.0") user: Int,
@Since("0.8.0") product: Int,
@Since("0.8.0") rating: Double)
So - if you mean to be filtering by user
, simply access that member instead of _1
: 所以-如果您要按user
过滤,则只需访问该成员而不是_1
:
val training_RDD = Ratingfiles.filter(x => x.user < 6)
.cache()
val validation_RDD = Ratingfiles.filter(x => x.user >= 6 && x.user < 8)
.cache()
Spark Rating class have 3 attributes (since spark 0.8.0) : Spark Rating类具有3个属性(自spark 0.8.0起):
If you want to get the first value, you need to invoke user()
; 如果要获取第一个值,则需要调用user()
; the second value product()
; 第二值product()
; the third value rating()
第三值rating()
sources : https://spark.apache.org/docs/1.4.0/api/java/org/apache/spark/mllib/recommendation/Rating.html 来源: https : //spark.apache.org/docs/1.4.0/api/java/org/apache/spark/mllib/recommendation/Rating.html
https://github.com/apache/spark/blob/master/mllib/src/main/scala/org/apache/spark/mllib/recommendation/ALS.scala https://github.com/apache/spark/blob/master/mllib/src/main/scala/org/apache/spark/mllib/recommendation/ALS.scala
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.