Course Slides
Course Slides
With Python
Section 1 : Introduction to Machine Learning
Section 2 : Implementing ML Algorithms in Python
Section 3 : Simple Linear Regression
Section 4 : Multiple Linear Regression
Section 5 : Classification Algorithms: K-Nearest Neighbors
Section 6 : Classification Algorithms: Decision Tree
Section 7 : Classification Algorithms: Logistic regression
Section 8 : Clustering
Section 9 : Recommender System
Section 10: Conclusion
Introduction to Machine Learning
Recommender System
Conclusion
Introduction to Machine Learning
Recommender System
Conclusion
Introduction to Machine Learning
Applications
Speech Recognition
Google translator
Netflix, YouTube, Amazon, and other such companies
Google maps, face detection to unlock a device, Siri, Cortana, Alexa all
these technologies use machine learning in the background
Introduction to Machine Learning
Recommender System
Conclusion
Machine Learning
Machine learning Methods
Introduction to Machine Learning
Recommender System
Conclusion
Machine Learning
What is Supervised learning?
The term "supervise" refers to the act of watching and directing the completion of a work, project, or
operation. It uses labelled training data and a collection of training sample to estimate a function.
Introduction to Machine Learning
Recommender System
Conclusion
Machine Learning
What is Unsupervised learning?
Unsupervised learning is a kind of machine learning in which the training data is supplied to the
system without any pre-assigned labels or values.
Introduction to Machine Learning
Recommender System
Conclusion
Machine Learning
Supervised learning vs Unsupervised learning
Quiz Time
Which of the following is TRUE about unsupervised machine learning?
Libraries of Python
Libraries of Python
Numpy helps to deal with Scipy used for scientific Matplotlib is a plotting
large, multi-dimensional computing and technical library, and it is easy to use
arrays and matrices, along computing. SciPy contains with Numpy because it’s
with a large collection of modules for optimization, linear numeric is integrated with
high-level mathematical algebra, integration, special Numpy.
functions to operate on functions, signal and image
these arrays. processing, and other tasks
common in science and
engineering.
Python Language for Machine Learning
Libraries of Python
What is Python?
• Python is one of the most popular programming languages,
created by Guido van Rossum and released in 1991.
• Python is an interpreted programming language as opposed
to a compiled programming language.
Why python?
• Python is a beginner-friendly language due to its simplified syntax which is close to natural
language.
• It has been designed to write clear, logical code for small and large-scale projects.
• It is used extensively in the industry for software development, data science, artificial
intelligence, and machine learning.
Setting Up Python
Python3 vs Python2
• Python2 is an outdated version of python. Python3 is the current version and is in-demand.
• In this course, we will be learning Python3 .
Setting Up Python – Windows (1/8)
• Visit: https://www.python.org/
Setting Up Python – Windows (2/8)
• Click on Downloads.
Setting Up Python – Windows (3/8)
• This will show you the latest version of Python3 for your operating system. Download it.
Setting Up Python – Windows (4/8)
• Installation wizard will open up. Make sure that ‘Add Python 3.9 to Path’ is checked. Click on
Install Now.
Setting Up Python – Windows (6/8)
• Once installed, type python in your search bar and click on ‘IDLE (Python 3.9 64-bit)’.
Setting Up Python – Windows (8/8)
• This will open up Python IDLE. Type print(“Hello”) and press Enter to execute.
Setting Up Python – Mac (1/13)
• Visit: https://www.python.org/
Setting Up Python – Mac (2/13)
• Click on Downloads.
Setting Up Python – Mac (3/13)
• This will show you the latest version of Python3 for your operating system. Download it.
Setting Up Python – Mac (4/13)
• Click continue.
Setting Up Python – Mac (6/13)
• Click continue.
Setting Up Python – Mac (7/13)
• Click continue.
Setting Up Python – Mac (8/13)
• Click continue.
Setting Up Python – Mac (10/13)
• Once installed, search for IDLE in your spotlight and click on it.
Setting Up Python – Mac (13/13)
• This will open up Python IDLE. Type print(“Hello World”) and press Enter to execute.
Introduction to Machine Learning
Introduction
Implementing ML Algorithms in Python
Python libraries for Machine
Learning
Simple Linear Regression
Setting up Python
Multiple Linear Regression
What is Jupyter?
Classification Algorithms: K-Nearest
Neighbors
Anaconda Installation for
Windows OS
Classification Algorithms: Decision Tree
Anaconda Installation for Mac OS
Classification Algorithms: Logistic
regression
Anaconda Installation for
Ubuntu OS
Clustering
Implementing Python in
Jupyter
Recommender System
Managing Directories in
Jupyter Notebook
Conclusion
Jupyter Notebook
• Visit: https://www.anaconda.com/products/individual
• Click on the Download button.
Anaconda for Windows (2/13)
• Click Next.
Anaconda for Windows (6/13)
• Click Install.
Anaconda for Windows (8/13)
• Click Finish.
Anaconda for Windows (10/13)
• To launch Jupyter Notebook, search for anaconda navigator and open it.
Anaconda for Windows (11/13)
• Visit: https://www.anaconda.com/
• Click on Get Started.
Anaconda for Mac (2/14)
• Once download, launch the installation wizard by double clicking on the file.
• Click Continue.
Anaconda for Mac (5/14)
• Click Install.
Anaconda for Mac (9/14)
• Click Continue.
Anaconda for Mac (10/14)
https://unibo.zoom.us/j/83422537997?pwd=Z3VENmI0QTV2Q2xJWDlPQzhrVU5PZz09
output
Introduction to Machine Learning
Introduction
Implementing ML Algorithms in Python
Python libraries for Machine
Learning
Simple Linear Regression
Setting up Python
Multiple Linear Regression
What is Jupyter?
Classification Algorithms: K-Nearest
Neighbors
Anaconda Installation for
Windows OS
Classification Algorithms: Decision Tree
Anaconda Installation for Mac OS
Classification Algorithms: Logistic
regression
Anaconda Installation for
Ubuntu OS
Clustering
Implementing Python in
Jupyter
Recommender System
Managing Directories in
Jupyter Notebook
Conclusion
Managing Directories in Jupyter Notebook – Windows (1/7)
• To open Jupyter Notebook in a particular directory/folder in windows, copy the path of the
directory.
Managing Directories in Jupyter Notebook – Windows (2/7)
• In your search bar type Anaconda Prompt and launch it
• Anaconda Prompt is the CLI of Anaconda
Managing Directories in Jupyter Notebook – Windows (3/7)
• Anaconda Prompt opens up in your C drive. Since we want to move to the D drive, we type d:
and hit enter.
Managing Directories in Jupyter Notebook – Windows (4/7)
• Next, to switch to the desired directory we type cd and then paste the path of the directory.
Managing Directories in Jupyter Notebook – Windows (5/7)
• Finally, we launch Jupyter Notebook by typing jupyter notebook.
• Jupyter Notebook takes a while to open.
Managing Directories in Jupyter Notebook – Windows (6/7)
• Once it opens, we can either open an existing notebook or create a new one.
• In this case we open the existing notebook named hello.ipynb.
Managing Directories in Jupyter Notebook – Windows (7/7)
• This is how hello.ipynb looks like.
Managing Directories in Jupyter Notebook – Mac (1/3)
• To open Jupyter Notebook in a particular directory/folder in Mac, open that directory in
terminal.
• Type ‘jupyter notebook’ without the quotation marks and hit Enter.
Managing Directories in Jupyter Notebook – Mac (2/3)
• Jupyter Notebook will launch in your browser.
• You can create a new Notebook or open an existing one.
• Let’s open this ‘hello.ipynb’ file.
Managing Directories in Jupyter Notebook – Mac (3/3)
• ‘hello.ipynb’ contains a simple print statement.
Managing Directories in Jupyter Notebook – Ubuntu (1/4)
• To open Jupyter Notebook in a particular directory/folder in Ubuntu, go to that directory, right
click and select ‘open in terminal’.
• Type ‘jupyter notebook’ without quotation marks and hit Enter.
Managing Directories in Jupyter Notebook – Ubuntu (2/4)
• Wait for sometime.
Managing Directories in Jupyter Notebook – Ubuntu (3/4)
• Jupyter Notebook will launch in your default browser.
• You can create a new Notebook or open an existing one.
• Let’s open this ‘hello.ipynb’ file.
Managing Directories in Jupyter Notebook – Ubuntu (4/4)
• ‘hello.ipynb’ contains a simple print statement.
Introduction to Machine Learning
Introduction to regression
Simple Linear Regression
How Does Linear Regression
Work?
Multiple Linear Regression
Line representation
Classification Algorithms: K-Nearest
Neighbors
Implementation in python:
Importing libraries & datasets
Classification Algorithms: Decision Tree
Implementation in python:
Classification Algorithms: Logistic Distribution of the data
regression
Implementation in python:
Creating a linear regression object
Clustering
Recommender System
Conclusion
Regression
Types of Regression
• Linear Regression
The relationship between input variables and output variable is linear.
1. Simple linear Regression: only single input variable is used to predict an output.
2. Multiple linear regression: more than one input variable is involved.
• Nonlinear Regression
Output is model by a function which is a nonlinear combination of the inputs.
Introduction to Machine Learning
Introduction to regression
Simple Linear Regression
How Does Linear Regression
Work?
Multiple Linear Regression
Line representation
Classification Algorithms: K-Nearest
Neighbors
Implementation in python:
Importing libraries & datasets
Classification Algorithms: Decision Tree
Implementation in python:
Classification Algorithms: Logistic Distribution of the data
regression
Implementation in python:
Creating a linear regression object
Clustering
Recommender System
Conclusion
Simple Linear Regression
Working of simple Linear Regression
Let’s consider the following example to explain the working of linear regression
Introduction to regression
Simple Linear Regression
How Does Linear Regression
Work?
Multiple Linear Regression
Line representation
Classification Algorithms: K-Nearest
Neighbors
Implementation in python:
Importing libraries & datasets
Classification Algorithms: Decision Tree
Implementation in python:
Classification Algorithms: Logistic Distribution of the data
regression
Implementation in python:
Creating a linear regression object
Clustering
Recommender System
Conclusion
Simple Linear Regression
Line representation
Y = mx + b
Introduction to regression
Simple Linear Regression
How Does Linear Regression
Work?
Multiple Linear Regression
Line representation
Classification Algorithms: K-Nearest
Neighbors
Implementation in python:
Importing libraries & datasets
Classification Algorithms: Decision Tree
Implementation in python:
Classification Algorithms: Logistic Distribution of the data
regression
Implementation in python:
Creating a linear regression object
Clustering
Recommender System
Conclusion
Simple Linear Regression
Simple Linear Regression in python
Introduction to regression
Simple Linear Regression
How Does Linear Regression
Work?
Multiple Linear Regression
Line representation
Classification Algorithms: K-Nearest
Neighbors
Implementation in python:
Importing libraries & datasets
Classification Algorithms: Decision Tree
Implementation in python:
Classification Algorithms: Logistic Distribution of the data
regression
Implementation in python:
Creating a linear regression object
Clustering
Recommender System
Conclusion
Simple Linear Regression
Introduction to regression
Simple Linear Regression
How Does Linear Regression
Work?
Multiple Linear Regression
Line representation
Classification Algorithms: K-Nearest
Neighbors
Implementation in python:
Importing libraries & datasets
Classification Algorithms: Decision Tree
Implementation in python:
Classification Algorithms: Logistic Distribution of the data
regression
Implementation in python:
Creating a linear regression object
Clustering
Recommender System
Conclusion
Simple Linear Regression
Simple Linear Regression in python
Introduction to Machine Learning
Implementation in python:
Multiple Linear Regression Encoding Categorical Data
Implementation in python:
Classification Algorithms: K-Nearest
Splitting data into Train and Test
Neighbors
Sets
Implementation in python:
Classification Algorithms: Decision Tree Training the model on the
Training set
Implementation in
Classification Algorithms: Logistic python: Predicting the
regression
Test Set results
Evaluating the performance of
Clustering
the regression model
Conclusion
Multiple Linear Regression
Simple Linear Regression Multiple Linear Regression
Introduction to Machine Learning
Implementation in python:
Multiple Linear Regression Encoding Categorical Data
Implementation in python:
Classification Algorithms: K-Nearest
Splitting data into Train and Test
Neighbors
Sets
Implementation in python:
Classification Algorithms: Decision Tree Training the model on the
Training set
Implementation in
Classification Algorithms: Logistic python: Predicting the
regression
Test Set results
Evaluating the performance of
Clustering
the regression model
Conclusion
Multiple Linear Regression
Dataset
Multiple Linear Regression
Implementation in python:
Multiple Linear Regression Encoding Categorical Data
Implementation in python:
Classification Algorithms: K-Nearest
Splitting data into Train and Test
Neighbors
Sets
Implementation in python:
Classification Algorithms: Decision Tree Training the model on the
Training set
Implementation in
Classification Algorithms: Logistic python: Predicting the
regression
Test Set results
Evaluating the performance of
Clustering
the regression model
Conclusion
Multiple Linear Regression
Encoding Categorical Data
X:
Multiple Linear Regression
Encoding Categorical Data
After Encoding, X:
Introduction to Machine Learning
Implementation in python:
Multiple Linear Regression Encoding Categorical Data
Implementation in python:
Classification Algorithms: K-Nearest
Splitting data into Train and Test
Neighbors
Sets
Implementation in python:
Classification Algorithms: Decision Tree Training the model on the
Training set
Implementation in
Classification Algorithms: Logistic python: Predicting the
regression
Test Set results
Evaluating the performance of
Clustering
the regression model
Conclusion
Multiple Linear Regression
Splitting the dataset into the Training set and Test set
Introduction to Machine Learning
Implementation in python:
Multiple Linear Regression Encoding Categorical Data
Implementation in python:
Classification Algorithms: K-Nearest
Splitting data into Train and Test
Neighbors
Sets
Implementation in python:
Classification Algorithms: Decision Tree Training the model on the
Training set
Implementation in
Classification Algorithms: Logistic python: Predicting the
regression
Test Set results
Evaluating the performance of
Clustering
the regression model
Conclusion
Multiple Linear Regression
Implementation in python:
Multiple Linear Regression Encoding Categorical Data
Implementation in python:
Classification Algorithms: K-Nearest
Splitting data into Train and Test
Neighbors
Sets
Implementation in python:
Classification Algorithms: Decision Tree Training the model on the
Training set
Implementation in
Classification Algorithms: Logistic python: Predicting the
regression
Test Set results
Evaluating the performance of
Clustering
the regression model
Conclusion
Multiple Linear Regression
Predicting the Test Set results
Implementation in python:
Multiple Linear Regression Encoding Categorical Data
Implementation in python:
Classification Algorithms: K-Nearest
Splitting data into Train and Test
Neighbors
Sets
Implementation in python:
Classification Algorithms: Decision Tree Training the model on the
Training set
Implementation in
Classification Algorithms: Logistic python: Predicting the
regression
Test Set results
Evaluating the performance of
Clustering
the regression model
Conclusion
Model Evaluation for Regression
Mean Absolute Error (MAE):
Number of values
Actual value
Predictive value
Implementation in python:
Multiple Linear Regression Encoding Categorical Data
Implementation in python:
Classification Algorithms: K-Nearest
Splitting data into Train and Test
Neighbors
Sets
Implementation in python:
Classification Algorithms: Decision Tree Training the model on the
Training set
Implementation in
Classification Algorithms: Logistic python: Predicting the
regression
Test Set results
Evaluating the performance of
Clustering
the regression model
Conclusion
Model Evaluation for Regression
A) AUC-ROC
B) Accuracy
C) Logloss
D) Mean-Squared-Error
Quiz Time
A) AUC-ROC
B) Accuracy
C) Logloss
D) Mean-Squared-Error
Introduction to Machine Learning Introduction to classification
Implementation in python:
Classification Algorithms: Decision Tree Importing the dataset
Implementation in python:
Classification Algorithms: Logistic Splitting data into Train and Test
regression Sets
Implementation in
Clustering python: Feature Scaling
Implementation in python:
Recommender System Importing the KNN classifier
Implementation in python:
Conclusion Results prediction & Confusion
matrix
Classification
Classification
Classification is a predictive modelling issue in machine learning where a class label is predicted for a
given sample of input data.
Application of Classification
• Filtering spam emails
• Speech and handwriting recognition
• Biometric
• Fingerprint recognition etc.
Algorithms of Classification
• Neural Networks
• Regression
• K-nearest neighbor
Introduction to Machine Learning Introduction to classification
Implementation in python:
Classification Algorithms: Decision Tree Importing the dataset
Implementation in python:
Classification Algorithms: Logistic Splitting data into Train and Test
regression Sets
Implementation in
Clustering python: Feature Scaling
Implementation in python:
Recommender System Importing the KNN classifier
Implementation in python:
Conclusion Results prediction & Confusion
matrix
K-Nearest Neighbours (KNN)
The K-Nearest Neighbors algorithm is a classification method that utilizes a set of labelled points
to learn how to identify new ones
Algorithm of KNN
• Choose a value for K.
• Determine the distance of an unknown point from
all other points.
• Now in training data set choose the K which are
nearest to the unknown data point.
• Now predict the response of unknown data point.
Introduction to Machine Learning Introduction to classification
Implementation in python:
Classification Algorithms: Decision Tree Importing the dataset
Implementation in python:
Classification Algorithms: Logistic Splitting data into Train and Test
regression Sets
Implementation in
Clustering python: Feature Scaling
Implementation in python:
Recommender System Importing the KNN classifier
Implementation in python:
Conclusion Results prediction & Confusion
matrix
K-Nearest Neighbours (KNN)
K-Nearest Neighbours (KNN)
• Example
KNN classifier will be use in this example to classify the input image into cat or dog.
Introduction to Machine Learning Introduction to classification
Implementation in python:
Classification Algorithms: Decision Tree Importing the dataset
Implementation in python:
Classification Algorithms: Logistic Splitting data into Train and Test
regression Sets
Implementation in
Clustering python: Feature Scaling
Implementation in python:
Recommender System Importing the KNN classifier
Implementation in python:
Conclusion Results prediction & Confusion
matrix
KNN Implementation
Implementation in python:
Classification Algorithms: Decision Tree Importing the dataset
Implementation in python:
Classification Algorithms: Logistic Splitting data into Train and Test
regression Sets
Implementation in
Clustering python: Feature Scaling
Implementation in python:
Recommender System Importing the KNN classifier
Implementation in python:
Conclusion Results prediction & Confusion
matrix
KNN Implementation
Implementation steps 1
• First, we will import the required libraries.
Introduction to Machine Learning Introduction to classification
Implementation in python:
Classification Algorithms: Decision Tree Importing the dataset
Implementation in python:
Classification Algorithms: Logistic Splitting data into Train and Test
regression Sets
Implementation in
Clustering python: Feature Scaling
Implementation in python:
Recommender System Importing the KNN classifier
Implementation in python:
Conclusion Results prediction & Confusion
matrix
KNN Implementation
Implementation steps 2
Implementation in python:
Classification Algorithms: Decision Tree Importing the dataset
Implementation in python:
Classification Algorithms: Logistic Splitting data into Train and Test
regression Sets
Implementation in
Clustering python: Feature Scaling
Implementation in python:
Recommender System Importing the KNN classifier
Implementation in python:
Conclusion Results prediction & Confusion
matrix
KNN Implementation
Implementation steps 3
Implementation in python:
Classification Algorithms: Decision Tree Importing the dataset
Implementation in python:
Classification Algorithms: Logistic Splitting data into Train and Test
regression Sets
Implementation in
Clustering python: Feature Scaling
Implementation in python:
Recommender System Importing the KNN classifier
Implementation in python:
Conclusion Results prediction & Confusion
matrix
KNN Implementation
K-Nearest Neighbours (KNN)in python
Unscaled data Scaled data
Introduction to Machine Learning Introduction to classification
Implementation in python:
Classification Algorithms: Decision Tree Importing the dataset
Implementation in python:
Classification Algorithms: Logistic Splitting data into Train and Test
regression Sets
Implementation in
Clustering python: Feature Scaling
Implementation in python:
Recommender System Importing the KNN classifier
Implementation in python:
Conclusion Results prediction & Confusion
matrix
KNN Implementation
Implementation steps 4
Implementation in python:
Classification Algorithms: Decision Tree Importing the dataset
Implementation in python:
Classification Algorithms: Logistic Splitting data into Train and Test
regression Sets
Implementation in
Clustering python: Feature Scaling
Implementation in python:
Recommender System Importing the KNN classifier
Implementation in python:
Conclusion Results prediction & Confusion
matrix
KNN Implementation
K-Nearest Neighbours (KNN)in python
Classification is-
A. Unsupervised learning
B. Reinforcement learning
C. Supervised learning
D. None
Quiz Time
Classification is-
A. Unsupervised learning
B. Reinforcement learning
C. Supervised learning
D. None
Introduction to Machine Learning
What is Entropy?
Simple Linear Regression
Implementation in python:
Classification Algorithms: Logistic
Encoding Categorical Data
regression
Implementation in python: Splitting
Clustering data into Train and Test Sets
Implementation in python:
Recommender System Results prediction & Accuracy
Conclusion
Decision Tree
What is decision tree?
Decision trees are a kind of Supervised Machine Learning in which data is continually segmented
based on a parameter.
What is Entropy?
Simple Linear Regression
Implementation in python:
Classification Algorithms: Logistic
Encoding Categorical Data
regression
Implementation in python: Splitting
Clustering data into Train and Test Sets
Implementation in python:
Recommender System Results prediction & Accuracy
Conclusion
Decision Tree
Entropy
P(x) is a probability
function of the event x to
take place
What is Entropy?
Simple Linear Regression
Implementation in python:
Classification Algorithms: Logistic
Encoding Categorical Data
regression
Implementation in python: Splitting
Clustering data into Train and Test Sets
Implementation in python:
Recommender System Results prediction & Accuracy
Conclusion
Decision Tree Implementation
Building a Decision Tree in python
Data set
Introduction to Machine Learning
What is Entropy?
Simple Linear Regression
Implementation in python:
Classification Algorithms: Logistic
Encoding Categorical Data
regression
Implementation in python: Splitting
Clustering data into Train and Test Sets
Implementation in python:
Recommender System Results prediction & Accuracy
Conclusion
Decision Tree Implementation
Building a Decision Tree in python
Decision tree
Introduction to Machine Learning
What is Entropy?
Simple Linear Regression
Implementation in python:
Classification Algorithms: Logistic
Encoding Categorical Data
regression
Implementation in python: Splitting
Clustering data into Train and Test Sets
Implementation in python:
Recommender System Results prediction & Accuracy
Conclusion
Decision Tree Implementation
Building a Decision Tree in python
Implementation steps 1
Implementation steps 3
• Split the data into features (Inputs - X) and Target variable (output y)
What is Entropy?
Simple Linear Regression
Implementation in python:
Classification Algorithms: Logistic
Encoding Categorical Data
regression
Implementation in python: Splitting
Clustering data into Train and Test Sets
Implementation in python:
Recommender System Results prediction & Accuracy
Conclusion
Decision Tree Implementation
Building a Decision Tree in python
Implementation steps 4
What is Entropy?
Simple Linear Regression
Implementation in python:
Classification Algorithms: Logistic
Encoding Categorical Data
regression
Implementation in python: Splitting
Clustering data into Train and Test Sets
Implementation in python:
Recommender System Results prediction & Accuracy
Conclusion
Decision Tree Implementation
Building a Decision Tree in python
Implementation steps 5
What is Entropy?
Simple Linear Regression
Implementation in python:
Classification Algorithms: Logistic
Encoding Categorical Data
regression
Implementation in python: Splitting
Clustering data into Train and Test Sets
Implementation in python:
Recommender System Results prediction & Accuracy
Conclusion
Decision Tree Implementation
Building a Decision Tree in python
Implementation steps 6
- Creating Decision Tree
- Use entropy to train the model
a) True
b) False
Quiz Time
a) True
b) False
Introduction to Machine Learning
Introduction
Implementing ML Algorithms in Python
Implementation steps
Simple Linear Regression
Implementation in python:
Multiple Linear Regression Importing libraries & datasets
Implementation in python:
Classification Algorithms: K-Nearest Splitting data into Train and Test
Neighbors Sets
Implementation in python: Pre-
Classification Algorithms: Decision Tree processing
Implementation in python:
Classification Algorithms: Logistic
Training the model
regression
Implementation in python: Results
Clustering prediction & Confusion matrix
Conclusion
Logistic Regression
What is logistic Regression?
The logistic model is used to predict the likelihood of a
specific class or occurrence.
Conditions to use logistic regression
• If the information is binary.
• If you require probabilistic outcomes.
• When a linear decision boundary is required.
Applications
• To forecast survival in wounded patients in the medical profession.
• To estimate the likelihood of a person suffering a heart attack.
• Predicting the likelihood of a procedure or product failing.
• Predicting a homeowner's possibility of defaulting on a lender.
Introduction to Machine Learning
Introduction
Implementing ML Algorithms in Python
Implementation steps
Simple Linear Regression
Implementation in python:
Multiple Linear Regression Importing libraries & datasets
Implementation in python:
Classification Algorithms: K-Nearest Splitting data into Train and Test
Neighbors Sets
Implementation in python: Pre-
Classification Algorithms: Decision Tree processing
Implementation in python:
Classification Algorithms: Logistic
Training the model
regression
Implementation in python: Results
Clustering prediction & Confusion matrix
Conclusion
Logistic Regression Implementation
Introduction
Implementing ML Algorithms in Python
Implementation steps
Simple Linear Regression
Implementation in python:
Multiple Linear Regression Importing libraries & datasets
Implementation in python:
Classification Algorithms: K-Nearest Splitting data into Train and Test
Neighbors Sets
Implementation in python: Pre-
Classification Algorithms: Decision Tree processing
Implementation in python:
Classification Algorithms: Logistic
Training the model
regression
Implementation in python: Results
Clustering prediction & Confusion matrix
Conclusion
Logistic Regression Implementation
Implementation step 1
• First, we will import the important libraries.
Logistic Regression Implementation
Implementation step 2
Introduction
Implementing ML Algorithms in Python
Implementation steps
Simple Linear Regression
Implementation in python:
Multiple Linear Regression Importing libraries & datasets
Implementation in python:
Classification Algorithms: K-Nearest Splitting data into Train and Test
Neighbors Sets
Implementation in python: Pre-
Classification Algorithms: Decision Tree processing
Implementation in python:
Classification Algorithms: Logistic
Training the model
regression
Implementation in python: Results
Clustering prediction & Confusion matrix
Conclusion
Logistic Regression Implementation
Implementation step 3
Introduction
Implementing ML Algorithms in Python
Implementation steps
Simple Linear Regression
Implementation in python:
Multiple Linear Regression Importing libraries & datasets
Implementation in python:
Classification Algorithms: K-Nearest Splitting data into Train and Test
Neighbors Sets
Implementation in python: Pre-
Classification Algorithms: Decision Tree processing
Implementation in python:
Classification Algorithms: Logistic
Training the model
regression
Implementation in python: Results
Clustering prediction & Confusion matrix
Conclusion
Logistic Regression Implementation
Implementation step 3
Introduction
Implementing ML Algorithms in Python
Implementation steps
Simple Linear Regression
Implementation in python:
Multiple Linear Regression Importing libraries & datasets
Implementation in python:
Classification Algorithms: K-Nearest Splitting data into Train and Test
Neighbors Sets
Implementation in python: Pre-
Classification Algorithms: Decision Tree processing
Implementation in python:
Classification Algorithms: Logistic
Training the model
regression
Implementation in python: Results
Clustering prediction & Confusion matrix
Conclusion
Logistic Regression Implementation
Introduction
Implementing ML Algorithms in Python
Implementation steps
Simple Linear Regression
Implementation in python:
Multiple Linear Regression Importing libraries & datasets
Implementation in python:
Classification Algorithms: K-Nearest Splitting data into Train and Test
Neighbors Sets
Implementation in python: Pre-
Classification Algorithms: Decision Tree processing
Implementation in python:
Classification Algorithms: Logistic
Training the model
regression
Implementation in python: Results
Clustering prediction & Confusion matrix
Conclusion
Logistic Regression Implementation
Logistic Regression in python
Prediction of results and confusion matrix
Now will predict the results and confusion matrix.
Introduction
Implementing ML Algorithms in Python
Implementation steps
Simple Linear Regression
Implementation in python:
Multiple Linear Regression Importing libraries & datasets
Implementation in python:
Classification Algorithms: K-Nearest Splitting data into Train and Test
Neighbors Sets
Implementation in python: Pre-
Classification Algorithms: Decision Tree processing
Implementation in python:
Classification Algorithms: Logistic
Training the model
regression
Implementation in python: Results
Clustering prediction & Confusion matrix
Conclusion
Logistic Regression Vs Linear Regression
A) TRUE
B) FALSE
Quiz Time
A) TRUE
B) FALSE
Solution: B
Use cases
Implementing ML Algorithms in Python
Implementation in python
Classification Algorithms: Decision Tree
Implementation of k-means
Recommender System clustering in python
Clustering
Recommender System
Conclusion
Clustering
What is Clustering?
Applications of Clustering
• Pattern recognition
• Spatial data analysis
• Image processing
• Document classification
• Identification of similar entities
• Finding pattern of weather behavior
Introduction to clustering
Introduction to Machine Learning
Use cases
Implementing ML Algorithms in Python
Implementation in python
Classification Algorithms: Decision Tree
Implementation of k-means
Recommender System clustering in python
Algorithms of Clustering
• K-Means Clustering
• Hierarchical Clustering
• Density-based Clustering
Introduction to clustering
Introduction to Machine Learning
Use cases
Implementing ML Algorithms in Python
Implementation in python
Classification Algorithms: Decision Tree
Implementation of k-means
Recommender System clustering in python
K-Means Clustering
It is an iterative algorithm that divides the unlabeled dataset into k different clusters in such a way
that each dataset belongs only one group that has similar properties.
Algorithms of K-Clustering
Use cases
Implementing ML Algorithms in Python
Implementation in python
Classification Algorithms: Decision Tree
Implementation of k-means
Recommender System clustering in python
Elbow method
This method uses the concept of WCSS value. WCSS stands for Within Cluster Sum of
Squares, which defines the total variations within a cluster. The formula to calculate the
value of WCSS.
Introduction to clustering
Introduction to Machine Learning
Use cases
Implementing ML Algorithms in Python
Implementation in python
Classification Algorithms: Decision Tree
Implementation of k-means
Recommender System clustering in python
•It executes the K-means clustering on a given dataset for different K values (ranges
from 1-10).
•For each value of K, calculates the WCSS value.
•Plots a curve between calculated WCSS values and the number of clusters K.
•The sharp point of bend or a point of the plot looks like an arm, then that point is
considered as the best value of K.
Introduction to clustering
Introduction to Machine Learning
Use cases
Implementing ML Algorithms in Python
Implementation in python
Classification Algorithms: Decision Tree
Implementation of k-means
Recommender System clustering in python
Use cases
Implementing ML Algorithms in Python
Implementation in python
Classification Algorithms: Decision Tree
Implementation of k-means
Recommender System clustering in python
Use cases
Implementing ML Algorithms in Python
Implementation in python
Classification Algorithms: Decision Tree
Implementation of k-means
Recommender System clustering in python
What is DBSCAN?
The most powerful attribute of DBSCAN algorithm is
that it can find out any arbitrary shape cluster
without getting effected by noise.
Advantages
• It can discover arbitrarily shaped cluster.
• Find cluster surrounded by different cluster.
• Robust towards noise detection.
Introduction to clustering
Introduction to Machine Learning
Use cases
Implementing ML Algorithms in Python
Implementation in python
Classification Algorithms: Decision Tree
Implementation of k-means
Recommender System clustering in python
Use cases
Implementing ML Algorithms in Python
Implementation in python
Classification Algorithms: Decision Tree
Implementation of k-means
Recommender System clustering in python
3D Visualization of the
Classification Algorithms: Decision Tree
predicted values
Clustering
Recommender System
Conclusion
Clustering
K-means clustering in python
Implementation step 4
- Visualize the dataset
Introduction to Machine Learning
3D Visualization of the
Classification Algorithms: Decision Tree
predicted values
Clustering
Recommender System
Conclusion
Clustering
K-means clustering in python
Implementation step 5
- Defining the Classifier
- Fit the kmeans
- Print the values of cluters coordinates
Introduction to Machine Learning
3D Visualization of the
Classification Algorithms: Decision Tree
predicted values
Clustering
Recommender System
Conclusion
Clustering
K-means clustering in python
Implementation step 6
- A 3D plot of our dataset
Introduction to Machine Learning
3D Visualization of the
Classification Algorithms: Decision Tree
predicted values
Clustering
Recommender System
Conclusion
Clustering
K-means clustering in python
Implementation step 7
- 3D plot of the prediction
Clusters
Introduction to Machine Learning
Clustering
Recommender System
Conclusion
Clustering
K-means clustering in python
Implementation step 7
Checking the predicted Values cluster number
Quiz Time
Answer: D
Explanation: because K-means clustering follows partitioning
approach.
Introduction to Machine Learning Introduction
Collaborative Filtering in
Implementing ML Algorithms in Python Recommender Systems
Content-based
Simple Linear Regression Recommender System
Implementation in python:
Multiple Linear Regression Importing libraries & datasets
Clustering
Repeating the process for
another movie
Recommender System
Conclusion
Recommender system
What is Recommender System?
Recommender systems are algorithms aimed at suggesting relevant items to users for example items
being movies to watch, text to read, products to buy or anything else depending on industries.
Applications
The applications of Recommender systems include movies, music, books, websites, documents,
television programs.
Benefits
Collaborative Filtering in
Implementing ML Algorithms in Python Recommender Systems
Content-based
Simple Linear Regression Recommender System
Implementation in python:
Multiple Linear Regression Importing libraries & datasets
The collaborative filtering method predicts the interests of a user on a product by collecting
preferences information from many other users.
Introduction to Machine Learning Introduction
Collaborative Filtering in
Implementing ML Algorithms in Python Recommender Systems
Content-based
Simple Linear Regression Recommender System
Implementation in python:
Multiple Linear Regression Importing libraries & datasets
Collaborative Filtering in
Implementing ML Algorithms in Python Recommender Systems
Content-based
Simple Linear Regression Recommender System
Implementation in python:
Multiple Linear Regression Importing libraries & datasets
Collaborative Filtering in
Implementing ML Algorithms in Python Recommender Systems
Content-based
Simple Linear Regression Recommender System
Implementation in python:
Multiple Linear Regression Importing libraries & datasets
Collaborative Filtering in
Implementing ML Algorithms in Python Recommender Systems
Content-based
Simple Linear Regression Recommender System
Implementation in python:
Multiple Linear Regression Importing libraries & datasets
Collaborative Filtering in
Implementing ML Algorithms in Python Recommender Systems
Content-based
Simple Linear Regression Recommender System
Implementation in python:
Multiple Linear Regression Importing libraries & datasets
Collaborative Filtering in
Implementing ML Algorithms in Python Recommender Systems
Content-based
Simple Linear Regression Recommender System
Implementation in python:
Multiple Linear Regression Importing libraries & datasets
Collaborative Filtering in
Implementing ML Algorithms in Python Recommender Systems
Content-based
Simple Linear Regression Recommender System
Implementation in python:
Multiple Linear Regression Importing libraries & datasets
Collaborative Filtering in
Implementing ML Algorithms in Python Recommender Systems
Content-based
Simple Linear Regression Recommender System
Implementation in python:
Multiple Linear Regression Importing libraries & datasets
Conclusion
Recommender system
Conclusion
Recommender system
Conclusion
Recommender system
- Use the corrwith() method to get the correlation between our most rated movies.
Recommender system
Clustering
Repeating the process for
another movie
Recommender System
Conclusion
Recommender system
Sorting by Correlation
Introduction to Machine Learning
Clustering
Repeating the process for
another movie
Recommender System
Conclusion
Recommender system
Clustering
Repeating the process for
another movie
Recommender System
Conclusion
Recommender system
Conclusion
Recommender system
Thank You!