Inverse classification with logistic and softmax classifiers: efficient optimization