avcontentteam — Updated On June 26th, 2020
Beginner Business Analytics Cheatsheet Infographics Machine Learning Python R


In his famous book – Think and Grow Rich, Napolean Hill narrates story of Darby, who after digging for a gold vein for a few years walks away from it when he was three feet away from it.

Now, I don’t know whether the story is true or false. But, I surely know of a few Data Darby around me. These people understand the purpose of machine learning, its execution and use just a set 2 – 3 algorithms on whatever problem they are working on. They don’t update themselves with better algorithms or techniques, because they are too tough or they are time consuming.

Like Darby, they are surely missing from a lot of action after reaching this close! In the end, they give up on machine learning by saying it is very computation heavy or it is very difficult or I can’t improve my models above a threshold – what’s the point? Have you heard them?

Today’s cheat sheet aims to change a few Data Darby’s to machine learning advocates. Here’s a collection of 10 most commonly used machine learning algorithms with their codes in Python and R. Considering the rising usage of machine learning in building models, this cheat sheet is good to act as a code guide to help you bring these machine learning algorithms to use. Good Luck!

For the super lazy Data Darbies, we will make your life even easier. You can download the PDF Version of the cheat sheet here and copy paste the codes from it directly.

machine learning algorithms, data science infographics

Keep this cheat sheet handy when you work on data sets. download the complete cheat sheet here: PDF Version

If you like what you just read & want to continue your analytics learning, subscribe to our emailsfollow us on twitter or join our Facebook Group

About the Author


Our Top Authors

Download Analytics Vidhya App for the Latest blog/Article

34 thoughts on "Cheatsheet – Python & R codes for common Machine Learning Algorithms"

venugopal says: September 15, 2015 at 4:37 am
Good Compilation... Reply
Indu says: September 15, 2015 at 2:11 pm
Thanks for sharing this in both R and Python. Very helpful. It would be nice to have datasets to accompany this code for those who are just starting out.... Reply
Huaixiu Zheng
Huaixiu Zheng says: September 17, 2015 at 4:27 pm
thanks for sharing Reply
Richard Boire
Richard Boire says: September 17, 2015 at 7:55 pm
This is good stuff. My only commentary is the following: I could not find anything in the code that deals with validation. This is a must in all models and their evaluation(i.e. how well the model performs in a holdout group). Evaluating the model based on its predicted output to observed output in the training data can be misleading because certain techniques have a tendency to overfit(i.e. neural nets) where holdout groups are essential in effectively evaluating model performance . Reply
Kayla says: September 18, 2015 at 1:08 pm
Awesome! Thank you! Reply
greg says: September 21, 2015 at 2:49 pm
thanks Reply
andun says: September 23, 2015 at 1:14 am
For kNN in R, the package knn is no longer available. The function knn can be found in the "class" package, but I don't think it takes the arguments the way you specified. I guess you can also use caret for that. Reply
Gaurav says: September 24, 2015 at 3:52 pm
Thx for sharing. In R we can implement stepwise regression.whats the equivalent in python. Reply
Raman says: October 12, 2015 at 3:42 am
Very thoughtfully compiled and presented. Thanks for posting something very useful! Reply
Jared says: November 13, 2015 at 3:32 pm
The download link has been invalid for China's mainland users. I tried to register the website but filed. Can someone please send the PDF file to my email ? Reply
Analytics Vidhya Content Team
Analytics Vidhya Content Team says: November 14, 2015 at 4:18 am
I've shared this PDF on your email. Reply
venugopal says: November 28, 2015 at 6:51 am
GooD one. Please share PDF file to my mail as well Reply
Shikhar Pandey
Shikhar Pandey says: November 29, 2015 at 10:58 am
Please share the PDF with me Reply
Analytics Vidhya Content Team
Analytics Vidhya Content Team says: November 30, 2015 at 6:05 am
Hi Venugopal Link to download is shared in the post above. You can very well download using the link. Thanks Reply
socialin says: December 28, 2015 at 1:30 am
"The reCAPTCHA wasn't entered correctly. Go back and try it again. (reCAPTCHA said: incorrect-captcha-sol)" The above messages prompted when I tried to register to download the pdf,I looked it up,it's about verify something,but I can't find the verify part anywhere.so that means I can't download it.Anyone know what's going on? Reply
socialin says: December 28, 2015 at 1:31 am
Can i get it in my email?Thanks! Reply
Analytics Vidhya Content Team
Analytics Vidhya Content Team says: December 28, 2015 at 4:13 am
Please share your email. Reply
socialin says: December 28, 2015 at 6:51 am
[email protected],Thanks! Reply
deepa says: February 01, 2016 at 7:35 am
thank you Reply
Manya says: February 10, 2016 at 4:31 pm
Thank you Reply
rajanikanth says: February 11, 2016 at 9:13 am
pl fix the download link Reply
dieudonne says: February 22, 2016 at 1:21 am
can i get a copy by my email? thank you . [email protected] Reply
Guilherme Cadori
Guilherme Cadori says: March 10, 2016 at 3:59 pm
Hey, Manish. Could you please share it with me as well? email: [email protected] For some reason the link is not available. Cheers, Reply
mobile live porn cam
mobile live porn cam says: June 09, 2016 at 10:10 pm
Can I simply just say what a comfort to uncover somebody that actually understands what they are discussing on the net. You certainly understand how to bring an issue to light and make it important. More people ought to read this and understand this side of your story. I was surprised that you aren't more popular given that you surely possess the gift. Reply
Tikbal says: June 15, 2016 at 1:36 am
there is a problem with the pdf link Reply
Juan Pablo Garicoïts
Juan Pablo Garicoïts says: July 17, 2016 at 8:59 pm
Nice compilation Reply
gelou88 says: August 23, 2016 at 9:35 pm
just to the point Reply
stephen says: August 26, 2016 at 5:32 am
Please share it with me thanks. Reply
Manoj says: August 26, 2016 at 10:31 am
Thanks for sharing. It's great help. Reply
Vighneshwar Eligeti
Vighneshwar Eligeti says: September 18, 2016 at 4:33 pm
can i get a copy by my email? thank you . el[email protected] Reply
Prateek Tandon
Prateek Tandon says: October 25, 2016 at 5:28 pm
Good work. For code snippets though, using gists is more friendly to make updates as per updates to libraries etc. Reply
Muhammad Fahmi Adli
Muhammad Fahmi Adli says: November 07, 2016 at 1:11 am
Can I get that copy code by email? Thank you. My email is [email protected]. Reply
Brenda says: November 10, 2016 at 2:21 am
please share the pdf to my email Thank you. God bless. Reply
Harsh says: January 04, 2017 at 10:48 am
Excellent piece of information. Posting both R and Python code is helpful in choosing which one to use for ML. Cheers! and Keep up the good work! Reply

Leave a Reply Your email address will not be published. Required fields are marked *