huaxingao commented on a change in pull request #28786:
URL: https://github.com/apache/spark/pull/28786#discussion_r438333447



##########
File path: 
mllib/src/test/scala/org/apache/spark/ml/regression/LinearRegressionSuite.scala
##########
@@ -899,6 +901,19 @@ class LinearRegressionSuite extends MLTest with 
DefaultReadWriteTest with PMMLRe
     }
   }
 
+  test("linear regression training summary totalIterations") {
+    Seq(1, 5, 10, 20).foreach { maxIter =>
+      val trainer = new 
LinearRegression().setSolver("l-bfgs").setMaxIter(maxIter)
+      val model = trainer.fit(datasetWithDenseFeature)
+      assert(model.summary.totalIterations <= maxIter)
+    }
+    Seq("auto", "normal").foreach { solver =>
+      val trainer = new LinearRegression().setSolver(solver)
+      val model = trainer.fit(datasetWithDenseFeature)
+      assert(model.summary.totalIterations === 0)

Review comment:
       before my change, summary.totalIterations is 1 for "normal". I think it 
should be 0 since Normal Equation is not an iterative method. totalIterations 
should be 0 too for "auto", since "auto" uses Normal Equation in this test (a 
small dataset).
   

##########
File path: python/pyspark/ml/tests/test_training_summary.py
##########
@@ -42,7 +42,7 @@ def test_linear_regression_summary(self):
         self.assertTrue(model.hasSummary)
         s = model.summary
         # test that api is callable and returns expected types
-        self.assertGreater(s.totalIterations, 0)
+        self.assertEqual(s.totalIterations, 0)

Review comment:
       solver="normal" in this case, so I think totalIterations should be 0. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to