def converge(self, x):
"""Finds cluster centers through an alternating optimization routine.
Terminates when either the number of cycles reaches `max_iter` or the
objective function changes by less than `tol`.
Parameters
----------
x : :obj:`np.ndarray`
(n_samples, n_features)
The original data.
"""
centers = []
j_new = np.infty
for i in range(self.max_iter):
j_old = j_new
self.update(x)
centers.append(self.centers)
j_new = self.objective(x)
if np.abs(j_old - j_new) < self.tol:
break
return np.array(centers)
评论列表
文章目录