Numpy Array Get row index searching by a row

Jestem nowy w numpy i wdrażam klastrowanie z random forest w Pythonie. Moje pytanie brzmi:

Jak mogę znaleźć indeks dokładnego wiersza w tablicy? Na przykład

[[ 0.  5.  2.]
 [ 0.  0.  3.]
 [ 0.  0.  0.]]

I szukam [0. 0. 3.] i otrzymuję jako wynik 1(indeks drugiego rzędu).

Jakieś sugestie? Postępuje zgodnie z kodem (nie działa...)
    for index, element in enumerate(leaf_node.x):
        for index_second_element, element_two in enumerate(leaf_node.x):
            if (index <= index_second_element):
                index_row = np.where(X == element)
                index_column = np.where(X == element_two)
                self.similarity_matrix[index_row][index_column] += 1
Author: user2801023, 2013-09-21

1 answers

Dlaczego po prostu nie zrobić czegoś takiego?

>>> a
array([[ 0.,  5.,  2.],
       [ 0.,  0.,  3.],
       [ 0.,  0.,  0.]])
>>> b
array([ 0.,  0.,  3.])

>>> a==b
array([[ True, False, False],
       [ True,  True,  True],
       [ True,  True, False]], dtype=bool)

>>> np.all(a==b,axis=1)
array([False,  True, False], dtype=bool)

>>> np.where(np.all(a==b,axis=1))
(array([1]),)
 42
Author: Daniel,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2013-09-21 00:53:10