How To Iterate Over A Numpy Matrix?
I have an matrix X = [[0. 0. 0. ... 0. 0. 0.] [0. 0. 0. ... 0. 0. 0.] [0. 0. 0. ... 0. 0. 0.] ...
Solution 1:
As a addition to @Eshwar S R's answer, this calculation can be done without a loop.
Is the output of the following code what you want?
loglike = np.sum(np.multiply(X_test, np.log(posprob)) + np.multiply((1-X_test), np.log(1-posprob)), axis=1)
Post a Comment for "How To Iterate Over A Numpy Matrix?"