Skip to content

Commit

Permalink
speedup thanks to removing unnecessary np.atleast_2d
Browse files Browse the repository at this point in the history
  • Loading branch information
nicodv committed Apr 28, 2015
1 parent 6950bd1 commit ac08188
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion kmodes/kmodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def get_max_value_key(dic):

def matching_dissim(a, b):
"""Simple matching dissimilarity function"""
return (np.atleast_2d(a) != b).sum(axis=1)
return np.sum(a != b, axis=1)


def init_huang(X, n_clusters):
Expand Down
2 changes: 1 addition & 1 deletion kmodes/kprototypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

def euclidean_dissim(a, b):
"""Euclidean distance dissimilarity function"""
return np.sum((np.atleast_2d(a) - b) ** 2, axis=1)
return np.sum((a - b) ** 2, axis=1)


def move_point_num(point, ipoint, to_clust, from_clust,
Expand Down

0 comments on commit ac08188

Please sign in to comment.