From bdecd1f447502e7ace8600a89ffa03bc66c1cc2c Mon Sep 17 00:00:00 2001 From: Herve Bredin Date: Fri, 30 Jan 2015 09:04:40 +0100 Subject: [PATCH] ENH: issue #4178 (cont.) --- sklearn/mixture/gmm.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sklearn/mixture/gmm.py b/sklearn/mixture/gmm.py index 4242fb28075..6c8e74bad30 100644 --- a/sklearn/mixture/gmm.py +++ b/sklearn/mixture/gmm.py @@ -234,9 +234,9 @@ class GMM(BaseEstimator): warnings.warn("'thresh' was replaced by 'tol' and will " "be removed in 0.18.", DeprecationWarning) - tol = 1e-1 * thresh self.n_components = n_components self.covariance_type = covariance_type + self.thresh = thresh self.tol = tol self.min_covar = min_covar self.random_state = random_state @@ -460,14 +460,20 @@ class GMM(BaseEstimator): log_likelihood = [] # reset self.converged_ to False self.converged_ = False + + # this line should be removed when 'thresh' is deprecated + tol = self.tol if self.thresh is None \ + else self.thresh / float(X.shape[0]) + for i in range(self.n_iter): # Expectation step curr_log_likelihood, responsibilities = self.score_samples(X) log_likelihood.append(curr_log_likelihood.mean()) # Check for convergence. + # (should compare to self.tol when 'thresh' is deprecated) if i > 0 and abs(log_likelihood[-1] - log_likelihood[-2]) < \ - self.tol: + tol: self.converged_ = True break