8
8
import numpy as np
9
9
import pytest
10
10
import scipy
11
- from numpy .testing import assert_allclose
12
11
from scipy import linalg
13
12
from scipy .optimize import minimize , root
14
13
28
27
from sklearn .linear_model ._linear_loss import LinearModelLoss
29
28
from sklearn .metrics import d2_tweedie_score , mean_poisson_deviance
30
29
from sklearn .model_selection import train_test_split
30
+ from sklearn .utils ._testing import assert_allclose
31
31
32
32
SOLVERS = ["lbfgs" , "newton-cholesky" ]
33
33
@@ -636,11 +636,11 @@ def test_glm_identity_regression(fit_intercept):
636
636
)
637
637
if fit_intercept :
638
638
glm .fit (X [:, 1 :], y )
639
- assert_allclose (glm .coef_ , coef [1 :], rtol = 1e-10 )
640
- assert_allclose (glm .intercept_ , coef [0 ], rtol = 1e-10 )
639
+ assert_allclose (glm .coef_ , coef [1 :])
640
+ assert_allclose (glm .intercept_ , coef [0 ])
641
641
else :
642
642
glm .fit (X , y )
643
- assert_allclose (glm .coef_ , coef , rtol = 1e-12 )
643
+ assert_allclose (glm .coef_ , coef )
644
644
645
645
646
646
@pytest .mark .parametrize ("fit_intercept" , [False , True ])
@@ -663,12 +663,12 @@ def test_glm_sample_weight_consistency(fit_intercept, alpha, GLMEstimator):
663
663
# sample_weight=np.ones(..) should be equivalent to sample_weight=None
664
664
sample_weight = np .ones (y .shape )
665
665
glm .fit (X , y , sample_weight = sample_weight )
666
- assert_allclose (glm .coef_ , coef , rtol = 1e-12 )
666
+ assert_allclose (glm .coef_ , coef )
667
667
668
668
# sample_weight are normalized to 1 so, scaling them has no effect
669
669
sample_weight = 2 * np .ones (y .shape )
670
670
glm .fit (X , y , sample_weight = sample_weight )
671
- assert_allclose (glm .coef_ , coef , rtol = 1e-12 )
671
+ assert_allclose (glm .coef_ , coef )
672
672
673
673
# setting one element of sample_weight to 0 is equivalent to removing
674
674
# the corresponding sample
@@ -677,7 +677,7 @@ def test_glm_sample_weight_consistency(fit_intercept, alpha, GLMEstimator):
677
677
glm .fit (X , y , sample_weight = sample_weight )
678
678
coef1 = glm .coef_ .copy ()
679
679
glm .fit (X [:- 1 ], y [:- 1 ])
680
- assert_allclose (glm .coef_ , coef1 , rtol = 1e-12 )
680
+ assert_allclose (glm .coef_ , coef1 )
681
681
682
682
# check that multiplying sample_weight by 2 is equivalent
683
683
# to repeating corresponding samples twice
0 commit comments