Here is the code in the slides, Quizzes and project of Practical Machine Learning a Coursera course.