From 0563a858d88442ed0e7cf36450b3c41a8bbaca4f Mon Sep 17 00:00:00 2001 From: Dante Gama Dessavre Date: Wed, 18 Dec 2024 22:40:41 -0600 Subject: [PATCH] Adjust margin of logistic regression `log_proba` pytest to avoid false positive failures (#6188) Not infrequently in CI we see errors in the comparison of Logistic Regression's `log_proba` arrays when compared to sklearn while the probabilities are within margin, this PR adjusts the margin to avoid that false positive failure. Authors: - Dante Gama Dessavre (https://github.com/dantegd) Approvers: - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/cuml/pull/6188 --- python/cuml/cuml/tests/test_linear_model.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/python/cuml/cuml/tests/test_linear_model.py b/python/cuml/cuml/tests/test_linear_model.py index 0d2d15686c..7960d4f0f8 100644 --- a/python/cuml/cuml/tests/test_linear_model.py +++ b/python/cuml/cuml/tests/test_linear_model.py @@ -772,7 +772,12 @@ def test_logistic_regression_predict_proba( sk_log_proba = sklog.predict_log_proba(X_test) assert array_equal(cu_proba, sk_proba) - assert array_equal(cu_log_proba, sk_log_proba) + + # if the probabilities pass test, then the margin of the logarithm + # of the probabilities can be relaxed to avoid false positives. + assert array_equal( + cu_log_proba, sk_log_proba, unit_tol=1e-2, total_tol=1e-3 + ) @pytest.mark.parametrize("constructor", [np.array, cp.array, cudf.DataFrame])