Finished logistic regression training algorithm