Implementation of basic machine learning algorithm