Multinomial logistic regression algorithm