[MRG] FIX for exception thrown when y does not have all classes

This is a fix for #3581
It seems that NumPy does something like this (when I googled)
    
    tmp1 = 1. / y_freq
    tmp2 = 0.0
    np.where(y_freq!=0, tmp1, tmp2)

I was thinking it would iterate all over all indices, evaluate the condition and then assign the value. Does the current behaviour not take a longer time?