new function to compute errors in the unbalanced data set case