BOW for unbalanced training sets