score:4

Accepted answer

Well if your model is outputting a zero probability for a given class, then the log probability for that class is negative infinity. So if you're summing over probabilities in the log space (or otherwise need this value), then obviously you can't work with this.

For this to occur in Random Forest, it means all of the trees are agreeing that the probability of this particular class for that particular data point is zero. You could mitigate this by increasing the number of trees (which would increase the chance at least one of them says that this example falls into that class). Or you could reduce the max_depth parameter to perhaps similar effect.

Alternatively you could just soften the outputs of your model before applying the logarithm, for instance by setting the output probabilities to min(max(p, 0.001), 0.999).

Hope that helps.


Related Query

More Query from same tag