class_docstr: Test MLlib algorithms on plain lists, to make sure they're passed through
  as NumPy arrays.
code: def test_regression(self):
      from pyspark.mllib.regression import (
          LinearRegressionWithSGD,
          LassoWithSGD,
          RidgeRegressionWithSGD,
      )
      from pyspark.mllib.tree import (
          DecisionTree,
          RandomForest,
          GradientBoostedTrees,
      )
  
      data = [
          LabeledPoint(-1.0, [0, -1]),
          LabeledPoint(1.0, [0, 1]),
          LabeledPoint(-1.0, [0, -2]),
          LabeledPoint(1.0, [0, 2]),
      ]
      rdd = self.sc.parallelize(data)
      features = [p.features.tolist() for p in data]
  
      lr_model = LinearRegressionWithSGD.train(rdd, iterations=10)
      self.assertTrue(lr_model.predict(features[0]) <= 0)
      self.assertTrue(lr_model.predict(features[1]) > 0)
      self.assertTrue(lr_model.predict(features[2]) <= 0)
      self.assertTrue(lr_model.predict(features[3]) > 0)
  
      lasso_model = LassoWithSGD.train(rdd, iterations=10)
      self.assertTrue(lasso_model.predict(features[0]) <= 0)
      self.assertTrue(lasso_model.predict(features[1]) > 0)
      self.assertTrue(lasso_model.predict(features[2]) <= 0)
      self.assertTrue(lasso_model.predict(features[3]) > 0)
  
      rr_model = RidgeRegressionWithSGD.train(rdd, iterations=10)
      self.assertTrue(rr_model.predict(features[0]) <= 0)
      self.assertTrue(rr_model.predict(features[1]) > 0)
      self.assertTrue(rr_model.predict(features[2]) <= 0)
      self.assertTrue(rr_model.predict(features[3]) > 0)
  
      categoricalFeaturesInfo = {0: 2}  # feature 0 has 2 categories
      dt_model = DecisionTree.trainRegressor(
          rdd,
          categoricalFeaturesInfo=categoricalFeaturesInfo,
          maxBins=4,
      )
      self.assertTrue(dt_model.predict(features[0]) <= 0)
      self.assertTrue(dt_model.predict(features[1]) > 0)
      self.assertTrue(dt_model.predict(features[2]) <= 0)
      self.assertTrue(dt_model.predict(features[3]) > 0)
  
      rf_model = RandomForest.trainRegressor(
          rdd,
          categoricalFeaturesInfo=categoricalFeaturesInfo,
          numTrees=10,
          maxBins=4,
          seed=1,
      )
      self.assertTrue(rf_model.predict(features[0]) <= 0)
      self.assertTrue(rf_model.predict(features[1]) > 0)
      self.assertTrue(rf_model.predict(features[2]) <= 0)
      self.assertTrue(rf_model.predict(features[3]) > 0)
  
      gbt_model = GradientBoostedTrees.trainRegressor(
          rdd,
          categoricalFeaturesInfo=categoricalFeaturesInfo,
          numIterations=4,
      )
      self.assertTrue(gbt_model.predict(features[0]) <= 0)
      self.assertTrue(gbt_model.predict(features[1]) > 0)
      self.assertTrue(gbt_model.predict(features[2]) <= 0)
      self.assertTrue(gbt_model.predict(features[3]) > 0)
  
      try:
          LinearRegressionWithSGD.train(
              rdd, initialWeights=array([1.0, 1.0]), iterations=10
          )
          LassoWithSGD.train(
              rdd, initialWeights=array([1.0, 1.0]), iterations=10
          )
          RidgeRegressionWithSGD.train(
              rdd, initialWeights=array([1.0, 1.0]), iterations=10
          )
      except ValueError:
          self.fail()
  
      # Verify that maxBins is being passed through
      GradientBoostedTrees.trainRegressor(
          rdd,
          categoricalFeaturesInfo=categoricalFeaturesInfo,
          numIterations=4,
          maxBins=32,
      )
      with self.assertRaises(Exception):
          GradientBoostedTrees.trainRegressor(
              rdd,
              categoricalFeaturesInfo=categoricalFeaturesInfo,
              numIterations=4,
              maxBins=1,
          )
  
imports: import os
  import tempfile
  from shutil import rmtree
  import unittest
  from numpy import array, array_equal
  from py4j.protocol import Py4JJavaError
  from pyspark.mllib.fpm import FPGrowth
  from pyspark.mllib.recommendation import Rating
  from pyspark.mllib.regression import LabeledPoint
  from pyspark.serializers import CPickleSerializer
  from pyspark.testing.mllibutils import MLlibTestCase
  from pyspark.testing.utils import eventually
label_desc: Use image node_id 8 for calling the ListTests obj's underlying member method code with example usage: obj.test_regression() without return types