[Python] Partially argsort a 2D array in Python

Discussão em 'Python' iniciado por Stack, Junho 20, 2025.

  1. Stack

    Stack Membro Participativo

    I have a KNN, and I need to partially argsort a list.

    Here is how it works right now in code:

    sorted_distance_indices = distances.argsort(axis=1)[:,:self.parameters['k']+1]

    kplus_1_nearest_classes = self.trainingY[sorted_distance_indices]

    ...etc.


    I found this answer, How can I partially sort a list? But I don't see how to adapt the 'heapification' for the argsort task, (and I have no idea how to do language interop in Python, so I don't see how to do the heapsort alg manually)...

    Continue reading...

Compartilhe esta Página