Skip to content

Commit

Permalink
don't keep re-using initial frequencies and memberships
Browse files Browse the repository at this point in the history
  • Loading branch information
nicodv committed Mar 11, 2022
1 parent aeb8bc4 commit 370d64b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions kmodes/kmodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ def _k_modes_single(X, n_clusters, n_points, n_attrs, max_iter, dissim, init, in
epoch_costs = [cost]
while itr < max_iter and not converged:
itr += 1
centroids, moves = _k_modes_iter(
centroids, cl_attr_freq, membship, moves = _k_modes_iter(
X,
centroids,
cl_attr_freq,
Expand Down Expand Up @@ -357,7 +357,7 @@ def _k_modes_iter(X, centroids, cl_attr_freq, membship, dissim, random_state):
X[rindx], rindx, old_clust, from_clust, cl_attr_freq, membship, centroids
)

return centroids, moves
return centroids, cl_attr_freq, membship, moves


def _move_point_cat(point, ipoint, to_clust, from_clust, cl_attr_freq,
Expand Down
10 changes: 5 additions & 5 deletions kmodes/kprototypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,10 @@ def _k_prototypes_single(Xnum, Xcat, nnumattrs, ncatattrs, n_clusters, n_points,
epoch_costs = [cost]
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,
membship, num_dissim, cat_dissim, gamma,
random_state)
centroids, cl_attr_sum, cl_memb_sum, cl_attr_freq, membship, moves = \
_k_prototypes_iter(Xnum, Xcat, centroids, cl_attr_sum, cl_memb_sum,
cl_attr_freq, membship, num_dissim, cat_dissim,
gamma, random_state)

# All points seen in this iteration
labels, ncost = labels_cost(Xnum, Xcat, centroids,
Expand Down Expand Up @@ -487,7 +487,7 @@ def _k_prototypes_iter(Xnum, Xcat, centroids, cl_attr_sum, cl_memb_sum, cl_attr_
cl_attr_freq, membship, centroids[1]
)

return centroids, moves
return centroids, cl_attr_sum, cl_memb_sum, cl_attr_freq, membship, moves


def _move_point_num(point, to_clust, from_clust, cl_attr_sum, cl_memb_sum):
Expand Down

0 comments on commit 370d64b

Please sign in to comment.