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

    https://github.com/apache/spark/pull/12464#discussion_r61491169
  
    --- Diff: python/pyspark/ml/tests.py ---
    @@ -461,6 +461,31 @@ def _fit(self, dataset):
     
     class CrossValidatorTests(PySparkTestCase):
     
    +    def test_copy(self):
    +        sqlContext = SQLContext(self.sc)
    +        dataset = sqlContext.createDataFrame([
    +            (10, 10.0),
    +            (50, 50.0),
    +            (100, 100.0),
    +            (500, 500.0)] * 10,
    +            ["feature", "label"])
    +
    +        iee = InducedErrorEstimator()
    +        evaluator = RegressionEvaluator(metricName="rmse")
    +
    +        grid = (ParamGridBuilder()
    +                .addGrid(iee.inducedError, [100.0, 0.0, 10000.0])
    +                .build())
    +        cv = CrossValidator(estimator=iee, estimatorParamMaps=grid, 
evaluator=evaluator)
    +        cvCopied = cv.copy()
    +        self.assertEqual(cv.getEstimator().uid, 
cvCopied.getEstimator().uid)
    +
    +        cvModel = cv.fit(dataset)
    +        cvModelCopied = cvModel.copy()
    +        for index in range(len(cvModel.avgMetrics)):
    +            self.assertTrue(abs(cvModel.avgMetrics[index] - 
cvModelCopied.avgMetrics[index])
    --- End diff --
    
    I have tried `assertEqual` before. This test case causes loss of precision 
under python2 if we use `assertEqual`. But under python3, it passes.


---
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