Logistic

Added logistic regression and generalized the core loop logic.