I cross-checked the implementation of sklearn with several other methods. This seems to be a real mistake in the framework. Instead, consider the following code to calculate log loss:
import scipy as sp def llfun(act, pred): epsilon = 1e-15 pred = sp.maximum(epsilon, pred) pred = sp.minimum(1-epsilon, pred) ll = sum(act*sp.log(pred) + sp.subtract(1,act)*sp.log(sp.subtract(1,pred))) ll = ll * -1.0/len(act) return ll
Also note that the sizes of act and pred must have column vectors Nx1.
source share