Github user techaddict commented on the pull request:
https://github.com/apache/spark/pull/597#issuecomment-42277501
@mengxr i'm bit confused.
```
val ratings = sc.textFile(input).map { line =>
val ratings = sc.textFile(params.input).map { line =>
val fields = line.split("::")
if (params.implicitPrefs) {
Rating(fields(0).toInt, fields(1).toInt, fields(2).toDouble - 2.5)
} else {
Rating(fields(0).toInt, fields(1).toInt, fields(2).toDouble)
}
}.cache()
```
```
val test = splits(1)
.map(x => Rating(x.user, x.product, if(x.rating>=0)1.0 else 0.0))
.cache()
```
```scala
def computeRmse(model: MatrixFactorizationModel, data: RDD[Rating], n:
Long) = {
val predictions: RDD[Rating] = model.predict(data.map(x => (x.user,
x.product)))
val predictionsAndRatings = predictions.map(x => ((x.user, x.product),
(x.rating + 2.5) / 5.0))
.join(data.map(x => ((x.user, x.product), x.rating)))
.values
math.sqrt(predictionsAndRatings.map(x => (x._1 - x._2) * (x._1 -
x._2)).mean())
}
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---