docstr: Test prediction on a model with weights already set.
code: def test_prediction(self):
      """Test prediction on a model with weights already set."""
      # Create a model with initial Weights equal to coefs
      slr = StreamingLinearRegressionWithSGD(
          stepSize=0.2, numIterations=25
      )
      slr.setInitialWeights([10.0, 10.0])
  
      # Create ten batches with 100 sample points in each.
      batches = []
      for i in range(10):
          batch = LinearDataGenerator.generateLinearInput(
              0.0,
              [10.0, 10.0],
              [0.0, 0.0],
              [1.0 / 3.0, 1.0 / 3.0],
              100,
              42 + i,
              0.1,
          )
          batches.append(
              self.sc.parallelize(batch).map(
                  lambda lp: (lp.label, lp.features)
              )
          )
  
      input_stream = self.ssc.queueStream(batches)
      output_stream = slr.predictOnValues(input_stream)
      samples = []
      output_stream.foreachRDD(lambda x: samples.append(x.collect()))
  
      self.ssc.start()
  
      def condition():
          self.assertEqual(len(samples), len(batches))
          return True
  
      # We want all batches to finish for this test.
      eventually(catch_assertions=True)(condition)()
  
      # Test that mean absolute error on each batch is less than 0.1
      for batch in samples:
          true, predicted = zip(*batch)
          self.assertTrue(
              mean(abs(array(true) - array(predicted))) < 0.1
          )
  
imports: import os
  import unittest
  from numpy import array, random, exp, dot, all, mean, abs
  from numpy import sum
  from pyspark import SparkContext
  from pyspark.mllib.clustering import StreamingKMeans, StreamingKMeansModel
  from pyspark.mllib.classification import StreamingLogisticRegressionWithSGD
  from pyspark.mllib.linalg import Vectors
  from pyspark.mllib.regression import LabeledPoint, StreamingLinearRegressionWithSGD
  from pyspark.mllib.util import LinearDataGenerator
  from pyspark.streaming import StreamingContext
  from pyspark.testing.utils import eventually
label_desc: Use image node_id 4 for calling the StreamingLinearRegressionWithTests obj's underlying member method code with example usage: obj.test_prediction() and returns: True