From 8f614fcfa7a35f60191f4d578a5b656a8083d665 Mon Sep 17 00:00:00 2001 From: Nico de Vos Date: Wed, 14 Jul 2021 21:36:16 -0700 Subject: [PATCH] iterations were running for 1 more than expected --- kmodes/kmodes.py | 2 +- kmodes/kprototypes.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kmodes/kmodes.py b/kmodes/kmodes.py index da00240..9b0c3da 100644 --- a/kmodes/kmodes.py +++ b/kmodes/kmodes.py @@ -306,7 +306,7 @@ def _k_modes_single(X, n_clusters, n_points, n_attrs, max_iter, dissim, init, in _, cost = labels_cost(X, centroids, dissim, membship) epoch_costs = [cost] - while itr <= max_iter and not converged: + while itr < max_iter and not converged: itr += 1 centroids, moves = _k_modes_iter( X, diff --git a/kmodes/kprototypes.py b/kmodes/kprototypes.py index 44d0f9d..87b54a1 100644 --- a/kmodes/kprototypes.py +++ b/kmodes/kprototypes.py @@ -416,7 +416,7 @@ def _k_prototypes_single(Xnum, Xcat, nnumattrs, ncatattrs, n_clusters, n_points, num_dissim, cat_dissim, gamma, membship) epoch_costs = [cost] - while itr <= max_iter and not converged: + while itr < max_iter and not converged: itr += 1 centroids, moves = _k_prototypes_iter(Xnum, Xcat, centroids, cl_attr_sum, cl_memb_sum, cl_attr_freq,