Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linear_assignment... What is it... #152

Closed
ehdrndd opened this issue Dec 30, 2021 · 2 comments
Closed

Linear_assignment... What is it... #152

ehdrndd opened this issue Dec 30, 2021 · 2 comments

Comments

@ehdrndd
Copy link

ehdrndd commented Dec 30, 2021

In

def linear_assignment(cost_matrix):
  try:
    import lap
    _, x, y = lap.lapjv(cost_matrix, extend_cost=True)
    return np.array([[y[i],i] for i in x if i >= 0]) #
  except ImportError:
    from scipy.optimize import linear_sum_assignment
    x, y = linear_sum_assignment(cost_matrix)
    return np.array(list(zip(x, y)))

image

above image is output of

import lap
_, x, y = lap.labjv(cost_matrix, extend_cost=True)

First, i understood variables as minimum_cost index of rows, cols. But, x[5]=-1, x[6]=4, y[4]=7. ?? I can't understand those values...

Second, there are differences lap.labjv with linear_sum_assignment

from scipy.optimize import linear_sum_assignment
x2, y2 = linear_sum_assignment(cost_matrix)

image

image

Can you help me?

@ehdrndd
Copy link
Author

ehdrndd commented Dec 30, 2021

I understood linear_sum_assignment!!

https://brc2.com/the-algorithm-workshop/

and my second question is trivial question. because rows 6,7 are all zeros..

@ehdrndd ehdrndd closed this as completed Dec 30, 2021
@microchila
Copy link

I would like to ask if the Hungarian algorithm can accept negative cost matrices?and what is the reason for sort to take a negative iou distance as a cost matrix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants