Python for Machine Learning
Anirudh Rao
Great Learning
Session Takeaways
Python for Machine Learning
● Why learn Python?
● Skills needed for Python Machine Learning
● Getting started with Machine Learning
● Practical implementation in Python
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Did you know?
Python is the world’s most popular programming language!
● Popular streaming services make use of Python extensively
● The name Python is derived from a TV show
● Very popular for Data Science
● Used by thousands of companies across the globe
● High-paying jobs with constant requirement
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Why learn Python?
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Why learn Python?
Built for Machine Learning
Purpose-built programming language
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Why learn Python?
Built to scale
● Interpreted language
● Easy to learn
● Built for dynamism
● Open source
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Why learn Python?
Python is a popular choice
● Huge library
● Large community
● Easy to read syntax
● Strongly typed language
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Skills needed for Machine
Learning using Python
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Skills needed for Python Machine Learning
Important requirements!
● Data oriented approach
● Out of the box thinking
● Logic building skills
● Ability to scale up quick
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Getting started with
Machine Learning!
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Machine Learning
The most important aspect of Data Science
● Forms to be an important application of Artificial Intelligence (AI)
● Programs learn from experience and improve on their own.
● The goal is to make machines more human-like.
● Where does it learn from?
● Datasets
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Machine Learning
Types of Machine Learning
● Supervised Learning
● Unsupervised Learning
● Reinforcement Learning
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Supervised Learning
● Presence of data and associated labels for the
data
Flowers Dumbbells Car
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Supervised Learning
Grouping
● Regression – Prediction of future values from past data
● Classification – Categorization of items using data.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Unsupervised Learning
● Goal of the algorithm is to find a structure present in the data.
● Nothing apart from the input variables are present.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Unsupervised Learning
Grouping
● Clustering – Grouping of input variables with similar characteristics.
● Association – Mapping associations based on data ( People will also watch..)
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Reinforcement Learning
● Trained based on the feedback from learning
● Algorithms work towards the rewards
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Practical implementation
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Machine Learning using Python
Let us take a look at two important algorithms
● Linear Regression
● KNN Algorithm
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Linear Regression
Linear Regression
● What is regression?
● Modelling a target value based on independent variables.
● Why is it so popular?
● Mainly used for finding out cause-effect relationship between variables.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Linear Regression
Let us implement a simple Linear Regression model!
● Boston housing data
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
K-NN Algorithm
K-Nearest Neighbour Algorithm
● Input data is indexed to find the closest neighbors.
● Data is compared in the inferencing phase to save time.
● Belongs to the category of lazy learners!
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
K-Nearest Neighbour Algorithm
Let us understand a simple KNN Classifier:
● Predict if person is male or female using KNN.
● Prediction is based on height and weight of the person.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
K-Nearest Neighbour Algorithm
Let us understand a simple KNN Classifier:
Height Weight Gender
187 80 Male
165 50 Female
199 99 Male
145 70 Female
180 87 Male
178 65 Female
187 60 Male
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
K-Nearest Neighbour Algorithm
Let us understand a simple KNN Classifier:
Now, need to add a new entry of a person
with height 190cm and weight 100kg.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
K-Nearest Neighbour Algorithm
Let us understand a simple KNN Classifier:
Added a new entry and plotted
the relevant graph for it.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
K-Nearest Neighbour Algorithm
Let us understand a simple KNN Classifier:
Assume k=3:
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
K-Nearest Neighbour Algorithm
Let us understand a simple KNN Classifier:
Note: Common practice to pick ‘k’ as an odd
Assume k=5:
number if there are two classes in comparison.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Machine Learning - Online
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Machine Learning - Online
Do not be overwhelmed by content!
● It is key that you as a learner is not overwhelmed by the wealth of data present online.
● Working on a structured learning path is key.
● Talking with experts in the industry and discussing about learning.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Machine Learning - Online
Free Content on Machine Learning
● Great Learning Academy
● Great Learning YouTube Channel
● Great Learning Blogs
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Machine Learning
Specialization
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited
Thank You!
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited