Skip to content

Commit 985ae28

Browse files
committed
fix tests
1 parent 35deb1c commit 985ae28

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

tests/tests_automl/test_automl_sample_weight.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import unittest
33

44
import numpy as np
5-
from numpy.testing import assert_almost_equal
65
from sklearn import datasets
76

87
from supervised import AutoML
@@ -20,10 +19,14 @@
2019

2120
class AutoMLSampleWeightTest(unittest.TestCase):
2221
automl_dir = "AutoMLSampleWeightTest"
22+
score_tolerance = 0.1
2323

2424
def tearDown(self):
2525
shutil.rmtree(self.automl_dir, ignore_errors=True)
2626

27+
def assert_score_close(self, score_1, score_2):
28+
self.assertLessEqual(abs(score_1 - score_2), self.score_tolerance)
29+
2730
def test_iris_dataset_sample_weight(self):
2831
"""Tests AutoML in the iris dataset (Multiclass classification)
2932
without and with sample weight"""
@@ -41,7 +44,7 @@ def test_iris_dataset_sample_weight(self):
4144
score_2 = model.fit(iris.data, iris.target, sample_weight=sample_weight).score(
4245
iris.data, iris.target, sample_weight=sample_weight
4346
)
44-
assert_almost_equal(score_1, score_2)
47+
self.assert_score_close(score_1, score_2)
4548

4649
def test_housing_dataset(self):
4750
"""Tests AutoML in the housing dataset (Regression)
@@ -62,7 +65,7 @@ def test_housing_dataset(self):
6265
score_2 = model.fit(
6366
housing[0], housing[1], sample_weight=sample_weight
6467
).score(housing[0], housing[1], sample_weight=sample_weight)
65-
assert_almost_equal(score_1, score_2)
68+
self.assert_score_close(score_1, score_2)
6669

6770
def test_breast_cancer_dataset(self):
6871
"""Tests AutoML in the breast cancer (binary classification)
@@ -83,4 +86,4 @@ def test_breast_cancer_dataset(self):
8386
score_2 = model.fit(
8487
breast_cancer.data, breast_cancer.target, sample_weight=sample_weight
8588
).score(breast_cancer.data, breast_cancer.target, sample_weight=sample_weight)
86-
assert_almost_equal(score_1, score_2)
89+
self.assert_score_close(score_1, score_2)

0 commit comments

Comments
 (0)