엔지니어스 - Engineeus

TypeError: tuple indices must be integers or slices, not tuple 본문

Autonomous Tech./Error (Windows & Ubuntu)

TypeError: tuple indices must be integers or slices, not tuple

Engineeus 2021. 8. 23. 09:09
728x90

<error>

TypeError: tuple indices must be integers or slices, not tuple

 

<problum is>

sklearn.utils.linear_assignment_ was replaced with scipy.optimize.linear_sum_assignment since the latter was pruned in the current version. I found the above function in a previous commit.

 

<solution>

Follows these steps to fix the bug.

  1. Comment out the import

# from scipy.optimize import linear_sum_assignment as linear_assignment

  1. Use pip to install lap
  2. Copy and paste the belmow function in the sort.py file

 

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)))
Comments