aboutsummaryrefslogtreecommitdiff
path: root/docs/mllib-guide.md
diff options
context:
space:
mode:
authorHossein Falaki <falaki@gmail.com>2014-01-02 16:22:13 -0800
committerHossein Falaki <falaki@gmail.com>2014-01-02 16:22:13 -0800
commit81989e26647ede54e19ef8058846e1bd42c0bfb5 (patch)
treeb7c4d9a8325a44d39d1972a7b40dc703dfe7d317 /docs/mllib-guide.md
parentc189c8362caeaa7a0f46af1c8e0d8d37fd171d7b (diff)
downloadspark-81989e26647ede54e19ef8058846e1bd42c0bfb5.tar.gz
spark-81989e26647ede54e19ef8058846e1bd42c0bfb5.tar.bz2
spark-81989e26647ede54e19ef8058846e1bd42c0bfb5.zip
Commented the last part of collaborative filtering examples that lead to errors
Diffstat (limited to 'docs/mllib-guide.md')
-rw-r--r--docs/mllib-guide.md11
1 files changed, 6 insertions, 5 deletions
diff --git a/docs/mllib-guide.md b/docs/mllib-guide.md
index e9d3785427..0bebc41137 100644
--- a/docs/mllib-guide.md
+++ b/docs/mllib-guide.md
@@ -297,8 +297,9 @@ val numIterations = 20
val model = ALS.train(ratings, 1, 20, 0.01)
// Evaluate the model on rating data
-val ratesAndPreds = ratings.map{ case Rating(user, item, rate) => (rate, model.predict(user, item))}
-val MSE = ratesAndPreds.map{ case(v, p) => math.pow((v - p), 2)}.reduce(_ + _)/ratesAndPreds.count
+//val ratesAndPreds = ratings.map{ case Rating(user, item, rate) => (rate, model.predict(user, item))}
+//val MSE = ratesAndPreds.map{ case(v, p) => math.pow((v - p), 2)}.reduce(_ + _)/ratesAndPreds.count
+//println("Mean Squared Error = " + MSE)
{% endhighlight %}
If the rating matrix is derived from other source of information (i.e., it is inferred from
@@ -406,9 +407,9 @@ ratings = data.map(lambda line: array([float(x) for x in line.split(',')]))
model = ALS.train(sc, ratings, 1, 20)
# Evaluate the model on training data
-ratesAndPreds = ratings.map(lambda p: (p[2], model.predict(int(p[0]), int(p[1]))))
-MSE = valuesAndPreds.map(lambda (v, p): (v - p)**2).reduce(lambda x, y: x + y)/valuesAndPreds.count()
-print("Mean Squared Error = " + str(MSE))
+#ratesAndPreds = ratings.map(lambda p: (p[2], model.predict(int(p[0]), int(p[1]))))
+#MSE = valuesAndPreds.map(lambda (v, p): (v - p)**2).reduce(lambda x, y: x + y)/valuesAndPreds.count()
+#print("Mean Squared Error = " + str(MSE))
{% endhighlight %}