@@ -521,7 +521,7 @@ print("Mean Squared Error = " + str(MSE))
521
521
## Streaming linear regression
522
522
523
523
When data arrive in a streaming fashion, it is useful to fit regression models online,
524
- updating the parameters of the model as new data arrive . MLlib currently supports
524
+ updating the parameters of the model as new data arrives . MLlib currently supports
525
525
streaming linear regression using ordinary least squares. The fitting is similar
526
526
to that performed offline, except fitting occurs on each batch of data, so that
527
527
the model continually updates to reflect the data from the stream.
@@ -546,10 +546,10 @@ import org.apache.spark.mllib.regression.StreamingLinearRegressionWithSGD
546
546
547
547
{% endhighlight %}
548
548
549
- Then we make input streams for training and testing data. We assume a Streaming Context ` ssc `
549
+ Then we make input streams for training and testing data. We assume a StreamingContext ` ssc `
550
550
has already been created, see [ Spark Streaming Programming Guide] ( streaming-programming-guide.html#initializing )
551
551
for more info. For this example, we use labeled points in training and testing streams,
552
- but in practice you will likely want to use unlabeled Vectors for test data.
552
+ but in practice you will likely want to use unlabeled vectors for test data.
553
553
554
554
{% highlight scala %}
555
555
@@ -562,8 +562,9 @@ We create our model by initializing the weights to 0
562
562
563
563
{% highlight scala %}
564
564
565
+ val numFeatures = 3
565
566
val model = new StreamingLinearRegressionWithSGD()
566
- .setInitialWeights(Vectors.zeros(3 ))
567
+ .setInitialWeights(Vectors.zeros(numFeatures ))
567
568
568
569
{% endhighlight %}
569
570
0 commit comments