You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by do...@apache.org on 2022/03/09 03:54:31 UTC

[spark] branch master updated: [MINOR][PYTHON] Fix `MultilayerPerceptronClassifierTest.test_raw_and_probability_prediction`

This is an automated email from the ASF dual-hosted git repository.

dongjoon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new 35c0e5c  [MINOR][PYTHON] Fix `MultilayerPerceptronClassifierTest.test_raw_and_probability_prediction`
35c0e5c is described below

commit 35c0e5cdf8e646203ce0310bfeee269addacdaa7
Author: Harutaka Kawamura <hk...@gmail.com>
AuthorDate: Tue Mar 8 19:53:19 2022 -0800

    [MINOR][PYTHON] Fix `MultilayerPerceptronClassifierTest.test_raw_and_probability_prediction`
    
    ### What changes were proposed in this pull request?
    
    - Increase `rtol`.
    - Use `numpy.testing.assert_allclose`.
    
    ### Why are the changes needed?
    
    - To make the flaky test less likely to fail.
    - To get a better assertion error message.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No
    
    ### How was this patch tested?
    
    Updated test
    
    Closes #35778 from harupy/fix-test_raw_and_probability_prediction.
    
    Authored-by: Harutaka Kawamura <hk...@gmail.com>
    Signed-off-by: Dongjoon Hyun <do...@apache.org>
---
 python/pyspark/ml/tests/test_algorithms.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/python/pyspark/ml/tests/test_algorithms.py b/python/pyspark/ml/tests/test_algorithms.py
index bf74988..08da859 100644
--- a/python/pyspark/ml/tests/test_algorithms.py
+++ b/python/pyspark/ml/tests/test_algorithms.py
@@ -101,7 +101,15 @@ class MultilayerPerceptronClassifierTest(SparkSessionTestCase):
         expected_rawPrediction = [-11.6081922998, -8.15827998691, 22.17757045]
         self.assertTrue(result.prediction, expected_prediction)
         self.assertTrue(np.allclose(result.probability, expected_probability, atol=1e-4))
-        self.assertTrue(np.allclose(result.rawPrediction, expected_rawPrediction, rtol=0.11))
+        # Use `assert_allclose` to show the value of `result.rawPrediction` in the assertion error
+        # message
+        np.testing.assert_allclose(
+            result.rawPrediction,
+            expected_rawPrediction,
+            rtol=0.15,
+            # Use the same default value as `np.allclose`
+            atol=1e-08,
+        )
 
 
 class OneVsRestTests(SparkSessionTestCase):

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org