2
$\begingroup$

I am trying to solve a problem where I need to group battery cells that are most similar to each other to form a reliable battery pack. It seems like a clustering problem but I only need to find the top 10 most similar cells from 100.

Is there any way i can solve this?

$\endgroup$
1
  • 1
    $\begingroup$ What sort of data has been given to you? $\endgroup$ Mar 26, 2021 at 12:23

2 Answers 2

1
$\begingroup$

That is often called nearest-neighbor search.

The most common methods require a distance metric. Given the features of battery pack, how close to each other are they?

$\endgroup$
1
  • $\begingroup$ Thanks for the hint. Actually, i am in the process of collecting data. $\endgroup$ Mar 31, 2021 at 6:16
1
$\begingroup$

As you mention it might be solved via clustering, but given you need the top n to each other you can go as follows:

Assuming you have matrix X of nxm (n- batteries m- features/attributes of each one)

  1. Define a distance metric (Euclidean, Mahalanobis, etc)
  2. Calculate the distance between a battery j and all the other batteries i - j
  3. Sort the top n distances from a battery

In pseudo code it will be something like this:

def kclosest(frame, battery_id, metric = "euclidean", top = 10):
    """
    Return the top n closest from battery id
    """
    distances = list()
    for index, row in frame.iterrows():
        d = metric(frame[frame.id == battery_id].values, row)
        distances.append(d)
    return sorted(distances)[1:top] # The closest point will always be the itself that's why we get from 1 to top
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.