Python machine learning predictive analysis core algorithm