Skip to content

Commit abbbf7e

Browse files
committed
update ALS argument names
1 parent 648283e commit abbbf7e

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

docs/mllib-collaborative-filtering.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ user for an item.
4848

4949
<div data-lang="scala" markdown="1">
5050
In the following example we load rating data. Each row consists of a user, a product and a rating.
51-
We use the default ALS.train() method which assumes ratings are explicit. We evaluate the
51+
We use the default [ALS.train()](api/mllib/index.html#org.apache.spark.mllib.recommendation.ALS$)
52+
method which assumes ratings are explicit. We evaluate the
5253
recommendation model by measuring the Mean Squared Error of rating prediction.
5354

5455
{% highlight scala %}
@@ -62,8 +63,9 @@ val ratings = data.map(_.split(',') match {
6263
})
6364

6465
// Build the recommendation model using ALS
66+
val rank = 10
6567
val numIterations = 20
66-
val model = ALS.train(ratings, 1, 20, 0.01)
68+
val model = ALS.train(ratings, rank, numIterations, 0.01)
6769

6870
// Evaluate the model on rating data
6971
val usersProducts = ratings.map{ case Rating(user, product, rate) => (user, product)}
@@ -83,7 +85,7 @@ If the rating matrix is derived from other source of information (i.e., it is in
8385
other signals), you can use the trainImplicit method to get better results.
8486

8587
{% highlight scala %}
86-
val model = ALS.trainImplicit(ratings, 1, 20, 0.01)
88+
val model = ALS.trainImplicit(ratings, rank, numIterations, 0.01)
8789
{% endhighlight %}
8890
</div>
8991

@@ -108,7 +110,9 @@ data = sc.textFile("mllib/data/als/test.data")
108110
ratings = data.map(lambda line: array([float(x) for x in line.split(',')]))
109111

110112
# Build the recommendation model using Alternating Least Squares
111-
model = ALS.train(ratings, 1, 20)
113+
rank = 10
114+
numIterations = 20
115+
model = ALS.train(ratings, rank, numIterations)
112116

113117
# Evaluate the model on training data
114118
testdata = ratings.map(lambda p: (int(p[0]), int(p[1])))
@@ -123,7 +127,7 @@ signals), you can use the trainImplicit method to get better results.
123127

124128
{% highlight python %}
125129
# Build the recommendation model using Alternating Least Squares based on implicit ratings
126-
model = ALS.trainImplicit(ratings, 1, 20)
130+
model = ALS.trainImplicit(ratings, rank, numIterations)
127131
{% endhighlight %}
128132
</div>
129133

0 commit comments

Comments
 (0)