[Python] Can this similarity measure between different size NumPy arrays be expressed entirely...

Discussão em 'Python' iniciado por Stack, Maio 19, 2025.

  1. Stack

    Stack Membro Participativo

    This script:

    import numpy as np
    from numpy.linalg import norm

    a = np.array([(1, 2, 3), (1, 4, 9), (2, 4, 4)])
    b = np.array([(1, 3, 3), (1, 5, 9)])
    r = sum([min(norm(a-e, ord=1, axis=1)) for e in b])


    computes a similarity measure r between different size NumPy arrays a and b. Is there a way to express it entirely with NumPy API for greater efficiency?

    Continue reading...

Compartilhe esta Página