python - Numpy syntax for mean -


while using python / numpy came across following syntax:

np.mean(predicted == docs_test.target) 

where arguments of type numpy.ndarray

what meaning of == here?

thanks, jaideep

assuming predicted , docs_test.target 2 arrays of same size, computes fraction of elements 2 arrays in exact agreement.

for example,

in [1]: import numpy np  in [2]: = np.array([1, 2, 3, 4, 5, 6, 7])  in [3]: b = np.array([1, 3, 7, 4, 5, 0, -10])  in [4]: np.mean(a == b) out[4]: 0.42857142857142855 

this telling in ~43% of cases (3 out of 7), a , b in agreement.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -