Generalized Machine Learning Code - R