Github user feynmanliang commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7099#discussion_r33984405
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/ml/regression/LinearRegressionSuite.scala 
---
    @@ -87,6 +86,42 @@ class LinearRegressionSuite extends SparkFunSuite with 
MLlibTestSparkContext {
               features(0) * model.weights(0) + features(1) * model.weights(1) 
+ model.intercept
             assert(prediction1 ~== prediction2 relTol 1E-5)
         }
    +
    +    // Training results for the model should be available
    +    assert(model.getTrainingResults.isDefined)
    +
    +    // Residuals in [[LinearRegressionResults]] should equal those 
manually computed
    +    dataset.select("features", "label").map {
    +      case Row(features: DenseVector, label: Double) =>
    +        val prediction =
    +          features(0) * model.weights(0) + features(1) * model.weights(1) 
+ model.intercept
    +        prediction - label
    +    }.zip(model.getTrainingResults.get.residuals.map(_.getDouble(0)))
    +      .collect()
    +      .foreach {
    +      case (manualResidual: Double, resultResidual: Double) =>
    --- End diff --
    
    Which comparison can be used for elementwise approximate equals with 
tolerance (I'm comparing two `Array[Double]`s)? I saw 
`IndexSeqOptimized#sameElements` but that tests for exact equality (`==`) and 
`TestingUtils` seems to only have stuff for `Vectors`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to