9
9
import numpy as np
10
10
11
11
from scipy import stats , linalg
12
+ import pytest
12
13
13
14
from sklearn .covariance import EmpiricalCovariance
14
15
from sklearn .datasets .samples_generator import make_spd_matrix
@@ -571,8 +572,15 @@ def test_gaussian_mixture_predict_predict_proba():
571
572
assert_greater (adjusted_rand_score (Y , Y_pred ), .95 )
572
573
573
574
574
- def test_gaussian_mixture_fit_predict ():
575
- rng = np .random .RandomState (0 )
575
+ @pytest .mark .filterwarnings ("ignore:.*did not converge.*" )
576
+ @pytest .mark .parametrize ('seed, max_iter,
ABE6
tol' , [
577
+ (0 , 2 , 1e-7 ), # strict non-convergence
578
+ (1 , 2 , 1e-1 ), # loose non-convergence
579
+ (3 , 300 , 1e-7 ), # strict convergence
580
+ (4 , 300 , 1e-1 ), # loose convergence
581
+ ])
582
+ def test_gaussian_mixture_fit_predict (seed , max_iter , tol ):
583
+ rng = np .random .RandomState (seed )
576
584
rand_data = RandomData (rng )
577
585
for covar_type in COVARIANCE_TYPE :
578
586
X = rand_data .X [covar_type ]
@@ -581,7 +589,8 @@ def test_gaussian_mixture_fit_predict():
581
589
random_state = rng , weights_init = rand_data .weights ,
582
590
means_init = rand_data .means ,
583
591
precisions_init = rand_data .precisions [covar_type ],
584
- covariance_type = covar_type )
592
+ covariance_type = covar_type ,
593
+ max_iter = max_iter , tol = tol )
585
594
586
595
# check if fit_predict(X) is equivalent to fit(X).predict(X)
587
596
f = copy .deepcopy (g )
0 commit comments