简体   繁体   English

值_1不是org.apache.spark.mllib.recommendation.Rating的成员

[英]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起):

  • user 用户
  • product 产品
  • rating 评分

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.

相关问题 错误:值recallAt 不是org.apache.spark.mllib.evaluation.RankingMetrics[Double] 的成员 - Error:value recallAt is not a member of org.apache.spark.mllib.evaluation.RankingMetrics[Double] 为什么import…RandomForest给出“对象RandomForest不是包org.apache.spark.mllib.tree的成员”? - Why does import …RandomForest give “object RandomForest is not a member of package org.apache.spark.mllib.tree”? 错误:对象 Stemmer 不是包 org.apache.spark.mllib.feature 的成员 - error: object Stemmer is not a member of package org.apache.spark.mllib.feature Apache Spark MLLib获得最大价值 - Apache Spark MLLib get maximum value 值映射不是org.apache.spark.sql.Row的成员 - value map is not a member of org.apache.spark.sql.Row 值toDF不是成员org.apache.spark.rdd.RDD - value toDF is not a member org.apache.spark.rdd.RDD value read不是org.apache.spark.SparkContext的成员 - value read is not a member of org.apache.spark.SparkContext value reduceByKey不是org.apache.spark.rdd.RDD的成员 - value reduceByKey is not a member of org.apache.spark.rdd.RDD 错误:值cassandraFormat不是org.apache.spark.sql.DataFrameWriter的成员 - Error: value cassandraFormat is not a member of org.apache.spark.sql.DataFrameWriter 值collectAsMap不是org.apache.spark.rdd.RDD的成员 - value collectAsMap is not a member of org.apache.spark.rdd.RDD
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM