Skip to content

Commit 42444d7

Browse files
committed
Based on Suggestions by mengxr
1 parent e3082fa commit 42444d7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

examples/src/main/scala/org/apache/spark/examples/mllib/MovieLensALS.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ object MovieLensALS {
9292

9393
val ratings = sc.textFile(params.input).map { line =>
9494
val fields = line.split("::")
95-
Rating(fields(0).toInt, fields(1).toInt, fields(2).toDouble)
95+
if (params.implicitPrefs) {
96+
Rating(fields(0).toInt, fields(1).toInt, if (fields(2).toInt >= 3) 1.0 else 0.0)
97+
} else {
98+
Rating(fields(0).toInt, fields(1).toInt, fields(2).toDouble)
99+
}
96100
}.cache()
97101

98102
val numRatings = ratings.count()

0 commit comments

Comments
 (0)