kitarp - 5 months ago 28

Python Question

I am trying to use a log loss function and keep getting the following error-

`AttributeError: log`

the line of code that is throwing this error is -

`ll = sum(act*sp.log(pred) + sp.subtract(1,act)*sp.log(sp.subtract(1,pred)))`

where pred is-

`[1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0......1]`

and act is-

`[[0 1]`

[1 1]

[2 1]

[3 1]

[4 1]

[5 1]

[6 1]

[7 1]

[8 1]

[9 1]

.

.

.

[n 1]]

Can someone help me with this? Completely driven up the wall.

Answer

@WarrenWeckesser's answer helped me-

"As a work-around, replace pred with pred.astype(int) (or pred.astype(float) if the values are floating point) in your expression for ll"