fix a bug by restricting the classes for logistic regression to be exactly range(n_classes)