Skip to content

Commit

Permalink
ENH: More speedups on Hungarian
Browse files Browse the repository at this point in the history
  • Loading branch information
GaelVaroquaux committed May 17, 2011
1 parent f805703 commit 562d5b3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions scikits/learn/utils/hungarian.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ def _step4(self):
"""
# We convert to int as numpy operations are faster on int
C = (self.C == 0).astype(np.int)
covered_C = C*self.row_uncovered[:, np.newaxis]
covered_C *= self.col_uncovered.astype(np.int)
n = self.n
while True:
# Find an uncovered zero
covered_C = C*self.row_uncovered[:, np.newaxis]
covered_C *= self.col_uncovered.astype(np.int)
raveled_idx = np.argmax(covered_C)
col = raveled_idx % n
row = raveled_idx // n
Expand All @@ -149,6 +149,10 @@ def _step4(self):
col = star_col
self.row_uncovered[row] = False
self.col_uncovered[col] = True
covered_C[:, col] = C[:, col]*(
self.row_uncovered.astype(np.int))
covered_C[row] = 0


def _step5(self):
"""
Expand Down

0 comments on commit 562d5b3

Please sign in to comment.