0% found this document useful (0 votes)
4 views

Course Slides

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Course Slides

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 276

Machine Learning

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

Implementing ML Algorithms in Python

Simple Linear Regression


What is Machine Learning?

Multiple Linear Regression Application of machine


learning
Classification Algorithms: K-Nearest
Neighbors Machine learning Methods

Classification Algorithms: Decision Tree


What is Supervised learning?
Classification Algorithms: Logistic
regression What is Unsupervised learning?

Clustering Supervised learning vs


Unsupervised learning

Recommender System

Conclusion
Introduction to Machine Learning

What is Machine Learning?


• Machine learning is a form of artificial intelligence, where the machine
are taught to do tasks without being explicitly programmed.

Characteristics of Machine Learning:

1. Learns relationship between data.

2. It can predict events for other data.

3. Improve performance with respect to experience.


Introduction to Machine Learning

Implementing ML Algorithms in Python

Simple Linear Regression


What is Machine Learning?

Multiple Linear Regression Application of machine


learning
Classification Algorithms: K-Nearest
Neighbors Machine learning Methods

Classification Algorithms: Decision Tree


What is Supervised learning?
Classification Algorithms: Logistic
regression What is Unsupervised learning?

Clustering Supervised learning vs


Unsupervised learning

Recommender System

Conclusion
Introduction to Machine Learning
Applications

Medical Diagnosis Self-Driving Cars Spam email Filtering

Stock market Trading Automatic Language Translation

Product Recommendations Traffic Prediction Image Recognition

Speech Recognition

And many more


Introduction to Machine Learning
Real World Applications

Detect cancer and brain tumours

Tesla self-driving car

Gmail spam emails filtering

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

Implementing ML Algorithms in Python

Simple Linear Regression


What is Machine Learning?

Multiple Linear Regression Application of machine


learning
Classification Algorithms: K-Nearest
Neighbors Machine learning Methods

Classification Algorithms: Decision Tree


What is Supervised learning?
Classification Algorithms: Logistic
regression What is Unsupervised learning?

Clustering Supervised learning vs


Unsupervised learning

Recommender System

Conclusion
Machine Learning
Machine learning Methods
Introduction to Machine Learning

Implementing ML Algorithms in Python

Simple Linear Regression


What is Machine Learning?

Multiple Linear Regression Application of machine


learning
Classification Algorithms: K-Nearest
Neighbors Machine learning Methods

Classification Algorithms: Decision Tree


What is Supervised learning?
Classification Algorithms: Logistic
regression What is Unsupervised learning?

Clustering Supervised learning vs


Unsupervised 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

Implementing ML Algorithms in Python

Simple Linear Regression


What is Machine Learning?

Multiple Linear Regression Application of machine


learning
Classification Algorithms: K-Nearest
Neighbors Machine learning Methods

Classification Algorithms: Decision Tree


What is Supervised learning?
Classification Algorithms: Logistic
regression What is Unsupervised learning?

Clustering Supervised learning vs


Unsupervised 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

Implementing ML Algorithms in Python

Simple Linear Regression


What is Machine Learning?

Multiple Linear Regression Application of machine


learning
Classification Algorithms: K-Nearest
Neighbors Machine learning Methods

Classification Algorithms: Decision Tree


What is Supervised learning?
Classification Algorithms: Logistic
regression What is Unsupervised learning?

Clustering Supervised learning vs


Unsupervised learning

Recommender System

Conclusion
Machine Learning
Supervised learning vs Unsupervised learning
Quiz Time
Which of the following is TRUE about unsupervised machine learning?

1. unsupervised learning comprises algorithms with no pre-existing


outcomes.
2. learning algorithms with no control over quality of their predictions.
3. a semi-autonomous machine learning where researchers control
some parts of the modelling process.
4. a fully autonomous machine learning with no human interference
Quiz Time
Which of the following is TRUE about unsupervised machine learning?

1. unsupervised learning comprises algorithms with no pre-existing


outcomes.
2. learning algorithms with no control over quality of their predictions.
3. a semi-autonomous machine learning where researchers control
some parts of the modelling process.
4. a fully autonomous machine learning with no human interference
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
Python Language for Machine Learning
Python
Python is a widely used and efficient programming language
that has lately become the language of choice for data
scientists.

Libraries of Python

Following are the few libraries of Python.


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
Python Language for Machine Learning

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

Scikit-learn (also known as sklearn) is a


Pandas is designed for data free software machine learning library for
manipulation and analysis. In the Python programming language. It
particular, it offers data structures and features various classification, regression
operations for manipulating numerical and clustering algorithms. And it is
tables and time series. designed to interoperate with the Python
numerical and scientific libraries NumPy
and SciPy.
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
Introduction to 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)

• Once downloaded, click Open.


Setting Up Python – Windows (5/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)

• It will take sometime to install.


Setting Up Python – Windows (7/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)

• Once downloaded, click on the file.


Setting Up Python – Mac (5/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)

• Read and accept the license agreement.


Setting Up Python – Mac (9/13)

• Click continue.
Setting Up Python – Mac (10/13)

• Click install. If prompted, enter your password.


Setting Up Python – Mac (11/13)

• Wait for the installation to finish.


Setting Up Python – Mac (12/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

• Jupyter Notebook is a web application that allows you to create


documents that may contain code, visualizations, and narrative
text.

• It is very popular and is used extensively in data science, artificial


intelligence, and machine learning.
https://unibo.zoom.us/j/83422537997?pwd=Z3VENmI0QTV2Q2xJWDlPQzhrVU5PZz09
• A notebook has the .ipynb extension

Alternatives to Jupyter Notebook


• Google Colaboratory is an alternative to Jupyter Notebook and does not require downloading
anything.
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
Anaconda for Windows (1/13)

• Visit: https://www.anaconda.com/products/individual
• Click on the Download button.
Anaconda for Windows (2/13)

• Once Downloaded, click on Open.


Anaconda for Windows (3/13)

• An installation Wizard will open up.


• Click on Next.
Anaconda for Windows (4/13)

• Read the License Agreement and click I Agree.


Anaconda for Windows (5/13)

• Click Next.
Anaconda for Windows (6/13)

• Choose the destination and click Next.


Anaconda for Windows (7/13)

• Click Install.
Anaconda for Windows (8/13)

• Wait for the installation to finish and click Next.


Anaconda for Windows (9/13)

• Click Finish.
Anaconda for Windows (10/13)

• To launch Jupyter Notebook, search for anaconda navigator and open it.
Anaconda for Windows (11/13)

• Following screen will open up.


• Launch Jupyter Notebook from here.
Anaconda for Windows (12/13)

• This will launch Jupyter Notebook in your default browser.


• Click on New -> Python3 to create a new Notebook.
Anaconda for Windows (13/13)

• This is how a Notebook looks like.


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
Anaconda for Mac (1/14)

• Visit: https://www.anaconda.com/
• Click on Get Started.
Anaconda for Mac (2/14)

• Click Download Anaconda Installers.


Anaconda for Mac (3/14)

• Download the graphical installer for Mac.


Anaconda for Mac (4/14)

• Once download, launch the installation wizard by double clicking on the file.
• Click Continue.
Anaconda for Mac (5/14)

• Read the Read Me file and click continue.


Anaconda for Mac (6/14)

• Read the License Agreement and click continue.


Anaconda for Mac (7/14)

• Select the destination and click Continue.


Anaconda for Mac (8/14)

• Click Install.
Anaconda for Mac (9/14)

• Click Continue.
Anaconda for Mac (10/14)

• Once the installation finishes, click Close.


Anaconda for Mac (11/14)

• Open your spotlight and click on Anaconda Navigator to launch it.


Anaconda for Mac (12/14)

• Launch Jupyter Notebook. It will take sometime to launch.


Anaconda for Mac (13/14)

• This will launch Jupyter Notebook in your default browser.


• Click on New -> Python3 to create a new Notebook.
Anaconda for Mac (14/14)

• This is how a Notebook looks like.


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
Anaconda for Ubuntu (1/11)
• Open your terminal, paste the following command, and hit enter
sudo apt install libgl1-mesa-glx libegl1-mesa libxrandr2 libxrandr2 libxss1 libxcursor1 libxcomposite1
libasound2 libxi6 libxtst6
• Type your password and hit Enter.
Anaconda for Ubuntu (2/11)
• Next give the following command and hit enter
wget https://repo.anaconda.com/archive/Anaconda3-2020.11-Linux-x86_64.sh -O
~/Downloads/Anaconda3-2020.11-Linux-x86_64.sh
Anaconda for Ubuntu (3/11)
• Next give the following command and hit enter
cd ~/Downloads
Anaconda for Ubuntu (4/11)
• Next give the following command and hit enter
sudo chmod +x Anaconda3-2020.11-Linux-x86_64.sh
Anaconda for Ubuntu (5/11)
• Next give the following command and hit enter
./Anaconda3-2020.11-Linux-x86_64.sh
• When prompted, press enter to continue.
Anaconda for Ubuntu (6/11)
• Press the Enter key to scroll through the License Agreement.
• After reading the Agreement, type yes in the prompt and hit enter.
Anaconda for Ubuntu (7/11)
• Anaconda installer will ask you where do you want to install Anaconda. We suggest pressing
Enter key to install it in the home directory.
• After sometime, Anaconda will be installed on your machine.
Anaconda for Ubuntu (8/11)
• Once installation is finished, you will be asked “Do you wish the installer to initialize
Anaconda3 by running conda init?” type “yes” and hit Enter. Setup will finish the installation
process.
Anaconda for Ubuntu (9/11)
• To launch Jupyter Notebook, restart your terminal.
• You will see (base) written before your home directory name.
• Type “jupyter notebook” without the quotation marks and hit enter.
• After a few minutes, Jupyter Notebook will run on your default browser.
Anaconda for Ubuntu (10/11)

• Click on New -> Python3 to create a new Notebook.


Anaconda for Ubuntu (11/11)

• This is how a Notebook looks like.


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
Implementing Python in Jupyter Notebook (1/2)

Upon launching Jupyter Notebook, this is what you will see!

This is where we write our


code, called a cell. You can
have as many of them as
you want.
Implementing Python in Jupyter Notebook (2/2)

• Write your Python code inside a cell.


• Select the cell by clicking on it and then click on the Run button to execute the code.
• Output of a cell is produced right below it.

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

Implementing ML Algorithms 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
Regression

Regression is a statistical method, which predicts a relationship of a continuous


outcome based on the value of one or more input variables.

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

Implementing ML Algorithms 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
Working of simple Linear Regression
Let’s consider the following example to explain the working of linear regression

What is the price of a house having an area of 330 square feet?


Introduction to Machine Learning

Implementing ML Algorithms 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
Line representation
Y = mx + b

Equation of line in terms of area and


price
Introduction to Machine Learning

Implementing ML Algorithms 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
Simple Linear Regression in python

Import the important libraries.

Import linear model from sklearn library.

Import the csv file of the data set.


Introduction to Machine Learning

Implementing ML Algorithms 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

Simple Linear Regression in python

Set x and y labels. x label


would be area and y label
would be price.
Introduction to Machine Learning

Implementing ML Algorithms 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
Simple Linear Regression in python
Introduction to Machine Learning

Implementing ML Algorithms in Python Understanding Multiple


linear regression
Implementation in python:
Simple Linear Regression Exploring the dataset

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

Root Mean Squared


Recommender System Error in Python

Conclusion
Multiple Linear Regression
Simple Linear Regression Multiple Linear Regression
Introduction to Machine Learning

Implementing ML Algorithms in Python Understanding Multiple


linear regression
Implementation in python:
Simple Linear Regression Exploring the dataset

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

Root Mean Squared


Recommender System Error in Python

Conclusion
Multiple Linear Regression

Multiple Linear Regression in python

Dataset
Multiple Linear Regression

Multiple Linear Regression in python


Introduction to Machine Learning

Implementing ML Algorithms in Python Understanding Multiple


linear regression
Implementation in python:
Simple Linear Regression Exploring the dataset

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

Root Mean Squared


Recommender System Error in Python

Conclusion
Multiple Linear Regression
Encoding Categorical Data
X:
Multiple Linear Regression
Encoding Categorical Data
After Encoding, X:
Introduction to Machine Learning

Implementing ML Algorithms in Python Understanding Multiple


linear regression
Implementation in python:
Simple Linear Regression Exploring the dataset

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

Root Mean Squared


Recommender System Error in Python

Conclusion
Multiple Linear Regression

Splitting the dataset into the Training set and Test set
Introduction to Machine Learning

Implementing ML Algorithms in Python Understanding Multiple


linear regression
Implementation in python:
Simple Linear Regression Exploring the dataset

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

Root Mean Squared


Recommender System Error in Python

Conclusion
Multiple Linear Regression

Training the Multiple Linear Regression model on the Training set


Introduction to Machine Learning

Implementing ML Algorithms in Python Understanding Multiple


linear regression
Implementation in python:
Simple Linear Regression Exploring the dataset

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

Root Mean Squared


Recommender System Error in Python

Conclusion
Multiple Linear Regression
Predicting the Test Set results

But, how to measure


how well our model
predicted?
Introduction to Machine Learning

Implementing ML Algorithms in Python Understanding Multiple


linear regression
Implementation in python:
Simple Linear Regression Exploring the dataset

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

Root Mean Squared


Recommender System Error in Python

Conclusion
Model Evaluation for Regression
Mean Absolute Error (MAE):
Number of values
Actual value

Predictive value

Mean Squared Error (MSE): Root Mean Squared Error (RMSE):


Introduction to Machine Learning

Implementing ML Algorithms in Python Understanding Multiple


linear regression
Implementation in python:
Simple Linear Regression Exploring the dataset

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

Root Mean Squared


Recommender System Error in Python

Conclusion
Model Evaluation for Regression

Python Code for Root Mean Squared Error (RMSE):


Quiz Time

Which of the following evaluation metrics can


be used to evaluate a model while modeling a
continuous output variable?

A) AUC-ROC
B) Accuracy
C) Logloss
D) Mean-Squared-Error
Quiz Time

Which of the following evaluation metrics can


be used to evaluate a model while modeling a
continuous output variable?

A) AUC-ROC
B) Accuracy
C) Logloss
D) Mean-Squared-Error
Introduction to Machine Learning Introduction to classification

Implementing ML Algorithms in Python K-Nearest Neighbors algorithm

Simple Linear Regression


Example of KNN

K-Nearest Neighbours (KNN)


Multiple Linear Regression using python

Classification Algorithms: K-Nearest Implementation in python:


Neighbors Importing required libraries

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

Implementing ML Algorithms in Python K-Nearest Neighbors algorithm

Simple Linear Regression


Example of KNN

K-Nearest Neighbours (KNN)


Multiple Linear Regression using python

Classification Algorithms: K-Nearest Implementation in python:


Neighbors Importing required libraries

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)

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

Implementing ML Algorithms in Python K-Nearest Neighbors algorithm

Simple Linear Regression


Example of KNN

K-Nearest Neighbours (KNN)


Multiple Linear Regression using python

Classification Algorithms: K-Nearest Implementation in python:


Neighbors Importing required libraries

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

Implementing ML Algorithms in Python K-Nearest Neighbors algorithm

Simple Linear Regression


Example of KNN

K-Nearest Neighbours (KNN)


Multiple Linear Regression using python

Classification Algorithms: K-Nearest Implementation in python:


Neighbors Importing required libraries

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

Steps to implement KNN

• Data pre-processing like filtering


• Fitting KNN to the training set.
• Predict the test results.
• Test accuracy of the results.
Introduction to Machine Learning Introduction to classification

Implementing ML Algorithms in Python K-Nearest Neighbors algorithm

Simple Linear Regression


Example of KNN

K-Nearest Neighbours (KNN)


Multiple Linear Regression using python

Classification Algorithms: K-Nearest Implementation in python:


Neighbors Importing required libraries

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

Implementation steps 1
• First, we will import the required libraries.
Introduction to Machine Learning Introduction to classification

Implementing ML Algorithms in Python K-Nearest Neighbors algorithm

Simple Linear Regression


Example of KNN

K-Nearest Neighbours (KNN)


Multiple Linear Regression using python

Classification Algorithms: K-Nearest Implementation in python:


Neighbors Importing required libraries

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

Implementation steps 2

• Then we will import the given data sets.

• Extract independent and dependent variables – X & y


Introduction to Machine Learning Introduction to classification

Implementing ML Algorithms in Python K-Nearest Neighbors algorithm

Simple Linear Regression


Example of KNN

K-Nearest Neighbours (KNN)


Multiple Linear Regression using python

Classification Algorithms: K-Nearest Implementation in python:


Neighbors Importing required libraries

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

Implementation steps 3

• Split the data into testing and training data set.

• Import sklearn for pre-processing and scale the features.


Introduction to Machine Learning Introduction to classification

Implementing ML Algorithms in Python K-Nearest Neighbors algorithm

Simple Linear Regression


Example of KNN

K-Nearest Neighbours (KNN)


Multiple Linear Regression using python

Classification Algorithms: K-Nearest Implementation in python:


Neighbors Importing required libraries

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

Implementing ML Algorithms in Python K-Nearest Neighbors algorithm

Simple Linear Regression


Example of KNN

K-Nearest Neighbours (KNN)


Multiple Linear Regression using python

Classification Algorithms: K-Nearest Implementation in python:


Neighbors Importing required libraries

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

Implementation steps 4

• Import the KNN classifier from sklearn library

Define the different parameters:


• n_neighbors
• metric='minkowski’.
• p=2.
Introduction to Machine Learning Introduction to classification

Implementing ML Algorithms in Python K-Nearest Neighbors algorithm

Simple Linear Regression


Example of KNN

K-Nearest Neighbours (KNN)


Multiple Linear Regression using python

Classification Algorithms: K-Nearest Implementation in python:


Neighbors Importing required libraries

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

Prediction of results and confusion matrix

- Now will predict the results using predict() method


- Get the confusion matrix using y_pred, y_test values
Correct predictions= 64+29 = 93
Incorrect predictions= 3+4 = 7
Quiz Time

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

Introduction to decision trees


Implementing ML Algorithms in Python

What is Entropy?
Simple Linear Regression

Exploring the dataset


Multiple Linear Regression

Classification Algorithms: K-Nearest Decision tree structure


Neighbors
Implementation in python:
Classification Algorithms: Decision Tree Importing libraries & datasets

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.

Learning algorithm of decision tree

• Choose a feature from the given data set.


• Determine the importance of feature in segmenting
of data.
• Data segmenting depend upon the best attribute.
• Now repeat the above steps.
Introduction to Machine Learning

Introduction to decision trees


Implementing ML Algorithms in Python

What is Entropy?
Simple Linear Regression

Exploring the dataset


Multiple Linear Regression

Classification Algorithms: K-Nearest Decision tree structure


Neighbors
Implementation in python:
Classification Algorithms: Decision Tree Importing libraries & datasets

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

It is the measure of the amount of uncertainty or randomness


in data.

P(x) is a probability
function of the event x to
take place

Lowest value: 0 (no randomness)


Highest vale: 1 (high randomness)
Introduction to Machine Learning

Introduction to decision trees


Implementing ML Algorithms in Python

What is Entropy?
Simple Linear Regression

Exploring the dataset


Multiple Linear Regression

Classification Algorithms: K-Nearest Decision tree structure


Neighbors
Implementation in python:
Classification Algorithms: Decision Tree Importing libraries & datasets

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

Introduction to decision trees


Implementing ML Algorithms in Python

What is Entropy?
Simple Linear Regression

Exploring the dataset


Multiple Linear Regression

Classification Algorithms: K-Nearest Decision tree structure


Neighbors
Implementation in python:
Classification Algorithms: Decision Tree Importing libraries & datasets

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

Introduction to decision trees


Implementing ML Algorithms in Python

What is Entropy?
Simple Linear Regression

Exploring the dataset


Multiple Linear Regression

Classification Algorithms: K-Nearest Decision tree structure


Neighbors
Implementation in python:
Classification Algorithms: Decision Tree Importing libraries & datasets

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

- Import the required libraries


Decision Tree Implementation
Building a Decision Tree in python
Implementation steps 2

- Define the data variables and import the data file


Decision Tree Implementation
Building a Decision Tree in python

Implementation steps 3

• Split the data into features (Inputs - X) and Target variable (output y)

• Target varible => Salary_more_then100k


• Defining Features for salary => company, job, degree
Introduction to Machine Learning

Introduction to decision trees


Implementing ML Algorithms in Python

What is Entropy?
Simple Linear Regression

Exploring the dataset


Multiple Linear Regression

Classification Algorithms: K-Nearest Decision tree structure


Neighbors
Implementation in python:
Classification Algorithms: Decision Tree Importing libraries & datasets

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

• Encode the categorical features into numerical values


• Use ordinal encoder
Decision Tree Implementation
Building a Decision Tree in python
Introduction to Machine Learning

Introduction to decision trees


Implementing ML Algorithms in Python

What is Entropy?
Simple Linear Regression

Exploring the dataset


Multiple Linear Regression

Classification Algorithms: K-Nearest Decision tree structure


Neighbors
Implementation in python:
Classification Algorithms: Decision Tree Importing libraries & datasets

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

- Split the data into training and testing sets


Introduction to Machine Learning

Introduction to decision trees


Implementing ML Algorithms in Python

What is Entropy?
Simple Linear Regression

Exploring the dataset


Multiple Linear Regression

Classification Algorithms: K-Nearest Decision tree structure


Neighbors
Implementation in python:
Classification Algorithms: Decision Tree Importing libraries & datasets

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

- Predict the results & Find the accuracy of the model


Quiz Time

Decision Trees can be used for Classification


Tasks.

a) True
b) False
Quiz Time

Decision Trees can be used for Classification


Tasks.

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

Logistic Regression vs Linear


Recommender System Regression

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

Logistic Regression vs Linear


Recommender System Regression

Conclusion
Logistic Regression Implementation

Logistic Regression in python

• Steps to implement Logistic Regression

• Data pre-processing like filtering


• Fitting KNN to the training set.
• Predict the test results.
• Test accuracy of the results.
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

Logistic Regression vs Linear


Recommender System Regression

Conclusion
Logistic Regression Implementation

Logistic Regression in python

Implementation step 1
• First, we will import the important libraries.
Logistic Regression Implementation

Logistic Regression in python

Implementation step 2

• we will import the given data sets.


• Extract independent and dependent variables.
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

Logistic Regression vs Linear


Recommender System Regression

Conclusion
Logistic Regression Implementation

Logistic Regression in python

Implementation step 3

• Split the data into testing and training data set.


• Import sklearn for pre-processing and scale the
features.
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

Logistic Regression vs Linear


Recommender System Regression

Conclusion
Logistic Regression Implementation

Logistic Regression in python

Implementation step 3

• Import sklearn for pre-processing and scale the


features.
Logistic Regression Implementation
Logistic Regression in python
Scaled data
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

Logistic Regression vs Linear


Recommender System Regression

Conclusion
Logistic Regression Implementation

Logistic Regression in python


Implementation step 4

• Fitting Logistic Regression classifier to training data


• Import sklearn and get our classifier – Logistic Regression
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

Logistic Regression vs Linear


Recommender System Regression

Conclusion
Logistic Regression Implementation
Logistic Regression in python
Prediction of results and confusion matrix
Now will predict the results and confusion matrix.

Correct predictions= 68+32 = 100


Incorrect predictions= 0
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

Logistic Regression vs Linear


Recommender System Regression

Conclusion
Logistic Regression Vs Linear Regression

Logistic Regression Linear Regression

• We estimate the values of categorical • We estimate the outcome of


variables using logistic regression. continuous variables using linear
• We discover the S-curve in Logistic regression.
Regression and use it to categorize the • In linear regression, we look for the
samples. best fit line, which allows us to predict
• It is not necessary to have a linear the outcome with ease.
connection between the dependent • It is necessary for the connection
and independent variables in logistic between the dependent and
regression. independent variables to be linear.
• There should be no collinearity • There is a possibility of collinearity
between the independent variables in between the independent factors in
logistic regression. linear regression.
Quiz Time

Is Logistic regression mainly used for


Regression?

A) TRUE
B) FALSE
Quiz Time

Is Logistic regression mainly used for


Regression?

A) TRUE
B) FALSE

Solution: B

Logistic regression is a classification algorithm, don’t confuse


with the name regression.
Introduction to clustering
Introduction to Machine Learning

Use cases
Implementing ML Algorithms in Python

Simple Linear Regression K-Means Clustering Algorithm

Multiple Linear Regression


Elbow method

Classification Algorithms: K-Nearest Steps of the Elbow method


Neighbors

Implementation in python
Classification Algorithms: Decision Tree

Classification Algorithms: Logistic Hierarchical clustering


regression

Clustering Density-based clustering

Implementation of k-means
Recommender System clustering in python

Conclusion Importing the dataset


Introduction to Machine Learning

Implementing ML Algorithms in Python

Simple Linear Regression Introduction to clustering

Multiple Linear Regression Use cases

Classification Algorithms: K-Nearest


K-Means Clustering Algorithm
Neighbors

Classification Algorithms: Decision Tree Elbow method

Classification Algorithms: Logistic


regression
Steps of the Elbow method

Clustering

Recommender System

Conclusion
Clustering
What is Clustering?

Clustering is an unsupervised learning; it is a


process of partitioning a set of data into a
meaningful sub-classes.

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

Simple Linear Regression K-Means Clustering Algorithm

Multiple Linear Regression


Elbow method

Classification Algorithms: K-Nearest Steps of the Elbow method


Neighbors

Implementation in python
Classification Algorithms: Decision Tree

Classification Algorithms: Logistic Hierarchical clustering


regression

Clustering Density-based clustering

Implementation of k-means
Recommender System clustering in python

Conclusion Importing the dataset


Clustering
Why do we need Clustering?

Clustering can be used for the following tasks:


• Analyzing data from the research
• Creating a summary
• Detecting noise
• Duplicate detection
• Procedures for pre-processing

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

Simple Linear Regression K-Means Clustering Algorithm

Multiple Linear Regression


Elbow method

Classification Algorithms: K-Nearest Steps of the Elbow method


Neighbors

Implementation in python
Classification Algorithms: Decision Tree

Classification Algorithms: Logistic Hierarchical clustering


regression

Clustering Density-based clustering

Implementation of k-means
Recommender System clustering in python

Conclusion Importing the dataset


Clustering

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

Following is an algorithm of K-Means Clustering:


• Partition clustering
• Without any cluster-internal structure, K-
Means divides data into non-overlapping
groups.
• Within a cluster, examples are very similar.
• Various clusters have quite different examples.
Introduction to clustering
Introduction to Machine Learning

Use cases
Implementing ML Algorithms in Python

Simple Linear Regression K-Means Clustering Algorithm

Multiple Linear Regression


Elbow method

Classification Algorithms: K-Nearest Steps of the Elbow method


Neighbors

Implementation in python
Classification Algorithms: Decision Tree

Classification Algorithms: Logistic Hierarchical clustering


regression

Clustering Density-based clustering

Implementation of k-means
Recommender System clustering in python

Conclusion Importing the dataset


Clustering

Determination of K in K-means clustering


The performance of the K-means clustering algorithm depends upon highly efficient
clusters that it forms. But choosing the optimal number of clusters is a big task.

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

Simple Linear Regression K-Means Clustering Algorithm

Multiple Linear Regression


Elbow method

Classification Algorithms: K-Nearest Steps of the Elbow method


Neighbors

Implementation in python
Classification Algorithms: Decision Tree

Classification Algorithms: Logistic Hierarchical clustering


regression

Clustering Density-based clustering

Implementation of k-means
Recommender System clustering in python

Conclusion Importing the dataset


Clustering
Steps of Elbow method

•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

Simple Linear Regression K-Means Clustering Algorithm

Multiple Linear Regression


Elbow method

Classification Algorithms: K-Nearest Steps of the Elbow method


Neighbors

Implementation in python
Classification Algorithms: Decision Tree

Classification Algorithms: Logistic Hierarchical clustering


regression

Clustering Density-based clustering

Implementation of k-means
Recommender System clustering in python

Conclusion Importing the dataset


Clustering
The Elbow method
Introduction to clustering
Introduction to Machine Learning

Use cases
Implementing ML Algorithms in Python

Simple Linear Regression K-Means Clustering Algorithm

Multiple Linear Regression


Elbow method

Classification Algorithms: K-Nearest Steps of the Elbow method


Neighbors

Implementation in python
Classification Algorithms: Decision Tree

Classification Algorithms: Logistic Hierarchical clustering


regression

Clustering Density-based clustering

Implementation of k-means
Recommender System clustering in python

Conclusion Importing the dataset


Clustering
What is Hierarchical Clustering?
It is an algorithm that groups similar objects into groups called
clusters. The endpoint is a set of clusters, where each cluster is
distinct from each other cluster, and the objects within each
cluster are broadly like each other.

Types of Hierarchical Clustering

There are two types of Hierarchical clustering:


• Divisive clustering is top to down approach in
which observations starts from large cluster and
splits into smaller ones.
• Agglomerative clustering is a bottom to top
approach in which observations start from many
clusters and merged as one cluster in the end.
Introduction to clustering
Introduction to Machine Learning

Use cases
Implementing ML Algorithms in Python

Simple Linear Regression K-Means Clustering Algorithm

Multiple Linear Regression


Elbow method

Classification Algorithms: K-Nearest Steps of the Elbow method


Neighbors

Implementation in python
Classification Algorithms: Decision Tree

Classification Algorithms: Logistic Hierarchical clustering


regression

Clustering Density-based clustering

Implementation of k-means
Recommender System clustering in python

Conclusion Importing the dataset


Clustering
What is Density-based Clustering?

Density-based clustering locates regions of high density and


separates outliers. So, the regions of high density get separated
from the regions of low density.

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

Simple Linear Regression K-Means Clustering Algorithm

Multiple Linear Regression


Elbow method

Classification Algorithms: K-Nearest Steps of the Elbow method


Neighbors

Implementation in python
Classification Algorithms: Decision Tree

Classification Algorithms: Logistic Hierarchical clustering


regression

Clustering Density-based clustering

Implementation of k-means
Recommender System clustering in python

Conclusion Importing the dataset


Clustering
K-means clustering in python
Implementation step 1

- Import the required dataset


Introduction to clustering
Introduction to Machine Learning

Use cases
Implementing ML Algorithms in Python

Simple Linear Regression K-Means Clustering Algorithm

Multiple Linear Regression


Elbow method

Classification Algorithms: K-Nearest Steps of the Elbow method


Neighbors

Implementation in python
Classification Algorithms: Decision Tree

Classification Algorithms: Logistic Hierarchical clustering


regression

Clustering Density-based clustering

Implementation of k-means
Recommender System clustering in python

Conclusion Importing the dataset


Clustering
K-means clustering in python
Implementation step 2

- Import the dataset


Clustering
K-means clustering in python
Implementation step 3
- HotEncoding of Gender
values
Introduction to Machine Learning

Implementing ML Algorithms in Python

Simple Linear Regression Visualizing the dataset

Multiple Linear Regression Defining the classifier

Classification Algorithms: K-Nearest


Neighbors 3D Visualization of the clusters

3D Visualization of the
Classification Algorithms: Decision Tree
predicted values

Classification Algorithms: Logistic Number of predicted


regression clusters

Clustering

Recommender System

Conclusion
Clustering
K-means clustering in python
Implementation step 4
- Visualize the dataset
Introduction to Machine Learning

Implementing ML Algorithms in Python

Simple Linear Regression Visualizing the dataset

Multiple Linear Regression Defining the classifier

Classification Algorithms: K-Nearest


3D Visualization of the clusters
Neighbors

3D Visualization of the
Classification Algorithms: Decision Tree
predicted values

Classification Algorithms: Logistic Number of predicted


regression clusters

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

Implementing ML Algorithms in Python

Simple Linear Regression Visualizing the dataset

Multiple Linear Regression Defining the classifier

Classification Algorithms: K-Nearest


3D Visualization of the clusters
Neighbors

3D Visualization of the
Classification Algorithms: Decision Tree
predicted values

Classification Algorithms: Logistic Number of predicted


regression clusters

Clustering

Recommender System

Conclusion
Clustering
K-means clustering in python
Implementation step 6
- A 3D plot of our dataset
Introduction to Machine Learning

Implementing ML Algorithms in Python

Simple Linear Regression Visualizing the dataset

Multiple Linear Regression Defining the classifier

Classification Algorithms: K-Nearest


Neighbors 3D Visualization of the clusters

3D Visualization of the
Classification Algorithms: Decision Tree
predicted values

Classification Algorithms: Logistic Number of predicted


regression clusters

Clustering

Recommender System

Conclusion
Clustering
K-means clustering in python
Implementation step 7
- 3D plot of the prediction
Clusters
Introduction to Machine Learning

Implementing ML Algorithms in Python

Simple Linear Regression Visualizing the dataset

Multiple Linear Regression Defining the classifier

Classification Algorithms: K-Nearest


3D Visualization of the clusters
Neighbors

Classification Algorithms: Decision Tree 3D Visualization of the


predicted values
Classification Algorithms: Logistic Number of predicted
regression clusters

Clustering

Recommender System

Conclusion
Clustering
K-means clustering in python
Implementation step 7
Checking the predicted Values cluster number
Quiz Time

Which of the following is required by K-means clustering?

A) defined distance metric


B) number of clusters
C) initial guess as to cluster centroids
D) all the mentioned
Quiz Time

Which of the following is required by K-means clustering?

A) defined distance metric


B) number of clusters
C) initial guess as to cluster centroids
D) all the mentioned

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

Classification Algorithms: K-Nearest Merging datasets into one


Neighbors dataframe

Sorting by title and rating


Classification Algorithms: Decision Tree

Classification Algorithms: Logistic Histogram showing


regression number of ratings

Clustering Frequency distribution

Jointplot of the ratings


Recommender System and number of ratings

Conclusion Data pre-processing


Introduction to Machine Learning

Implementing ML Algorithms in Python


Sorting the most-rated movies

Simple Linear Regression


Grab the ratings for two movies

Multiple Linear Regression Correlation between the


most-rated movies
Classification Algorithms: K-Nearest
Neighbors Sorting the data by correlation

Classification Algorithms: Decision Tree


Filtering out movies
Classification Algorithms: Logistic
regression
Sorting values

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

• Increase customer engagement.


• Increase customer satisfaction by delivering relevant content.
• Reduce the time of content searching.
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

Classification Algorithms: K-Nearest Merging datasets into one


Neighbors dataframe

Sorting by title and rating


Classification Algorithms: Decision Tree

Classification Algorithms: Logistic Histogram showing


regression number of ratings

Clustering Frequency distribution

Jointplot of the ratings


Recommender System and number of ratings

Conclusion Data pre-processing


Recommender system

Collaborative filtering Recommendation system

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

Classification Algorithms: K-Nearest Merging datasets into one


Neighbors dataframe

Sorting by title and rating


Classification Algorithms: Decision Tree

Classification Algorithms: Logistic Histogram showing


regression number of ratings

Clustering Frequency distribution

Jointplot of the ratings


Recommender System and number of ratings

Conclusion Data pre-processing


Recommender system

Content-based Recommender System


Content-based filtering method utilizes product features to recommend other products like
what the user likes, based on other users’ previous actions or explicit feedback such as rating
on products.
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

Classification Algorithms: K-Nearest Merging datasets into one


Neighbors dataframe

Sorting by title and rating


Classification Algorithms: Decision Tree

Classification Algorithms: Logistic Histogram showing


regression number of ratings

Clustering Frequency distribution

Jointplot of the ratings


Recommender System and number of ratings

Conclusion Data pre-processing


Recommender system

Recommender System in python


Implementation step 1

- Import the libraries


- Get the datasets
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

Classification Algorithms: K-Nearest Merging datasets into one


Neighbors dataframe

Sorting by title and rating


Classification Algorithms: Decision Tree

Classification Algorithms: Logistic Histogram showing


regression number of ratings

Clustering Frequency distribution

Jointplot of the ratings


Recommender System and number of ratings

Conclusion Data pre-processing


Recommender system

Recommender System in python


Implementation step 2

- Merge the two tables


- Using item_id
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

Classification Algorithms: K-Nearest Merging datasets into one


Neighbors dataframe

Sorting by title and rating


Classification Algorithms: Decision Tree

Classification Algorithms: Logistic Histogram showing


regression number of ratings

Clustering Frequency distribution

Jointplot of the ratings


Recommender System and number of ratings

Conclusion Data pre-processing


Recommender system

Recommender System in python


Implementation step 3

- Sort the rows by group of


Title, and rating
Find :-
- Count
- Mean
Recommender system
Recommender System in python
Implementation step 4

- Sort the rows by group of titles and rating

- Create a new column


And Put number of
ratings
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

Classification Algorithms: K-Nearest Merging datasets into one


Neighbors dataframe

Sorting by title and rating


Classification Algorithms: Decision Tree

Classification Algorithms: Logistic Histogram showing


regression number of ratings

Clustering Frequency distribution

Jointplot of the ratings


Recommender System and number of ratings

Conclusion Data pre-processing


Recommender system
Recommender System in python
Implementation step 5

- Plot the Newly created column


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

Classification Algorithms: K-Nearest Merging datasets into one


Neighbors dataframe

Sorting by title and rating


Classification Algorithms: Decision Tree

Classification Algorithms: Logistic Histogram showing


regression number of ratings

Clustering Frequency distribution

Jointplot of the ratings


Recommender System and number of ratings

Conclusion Data pre-processing


Recommender system
Recommender System in python
Implementation step 6

- Histogram of the ratings


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

Classification Algorithms: K-Nearest Merging datasets into one


Neighbors dataframe

Sorting by title and rating


Classification Algorithms: Decision Tree

Classification Algorithms: Logistic Histogram showing


regression number of ratings

Clustering Frequency distribution

Jointplot of the ratings


Recommender System and number of ratings

Conclusion Data pre-processing


Recommender system

Recommender System in python


Implementation step 7

- A combined plot of number of


Ratings and number of ratings
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

Classification Algorithms: K-Nearest Merging datasets into one


Neighbors dataframe

Sorting by title and rating


Classification Algorithms: Decision Tree

Classification Algorithms: Logistic Histogram showing


regression number of ratings

Clustering Frequency distribution

Jointplot of the ratings


Recommender System and number of ratings

Conclusion Data pre-processing


Recommender system
Recommender System in python
Implementation step 8

Importing the dataset movies and pre-processing it


Introduction to Machine Learning

Implementing ML Algorithms in Python


Sorting the most-rated movies

Simple Linear Regression


Grab the ratings for two movies

Multiple Linear Regression


Correlation between the
most-rated movies
Classification Algorithms: K-Nearest
Neighbors
Sorting the data by correlation

Classification Algorithms: Decision Tree


Filtering out movies
Classification Algorithms: Logistic
regression
Sorting values
Clustering
Repeating the process for
another movie
Recommender System

Conclusion
Recommender system

Recommender System in python


Implementation step 9

- Sorting the most rated movies


Introduction to Machine Learning

Implementing ML Algorithms in Python


Sorting the most-rated movies

Simple Linear Regression Grab the ratings for two movies

Multiple Linear Regression Correlation between the


most-rated movies
Classification Algorithms: K-Nearest
Neighbors Sorting the data by correlation

Classification Algorithms: Decision Tree


Filtering out movies

Classification Algorithms: Logistic


regression Sorting values

Clustering Repeating the process for


another movie
Recommender System

Conclusion
Recommender system

Recommender System in python


Implementation step 10

- Grab the Users ratings for two


Movies

- Star wars (1997)


- Liar Liar (1997)
Introduction to Machine Learning

Implementing ML Algorithms in Python


Sorting the most-rated movies
Simple Linear Regression
Grab the ratings for two movies

Multiple Linear Regression


Correlation between the
most-rated movies
Classification Algorithms: K-Nearest
Neighbors
Sorting the data by correlation

Classification Algorithms: Decision Tree


Filtering out movies
Classification Algorithms: Logistic
regression
Sorting values
Clustering
Repeating the process for
another movie
Recommender System

Conclusion
Recommender system

Recommender System in python


Implementation step 11

- Use the corrwith() method to get the correlation between our most rated movies.
Recommender system

Recommender System in python


Implementation step 12

Clean all the NaN and Use DataFrame instead of Series


Introduction to Machine Learning

Implementing ML Algorithms in Python


Sorting the most-rated movies

Simple Linear Regression


Grab the ratings for two movies

Multiple Linear Regression Correlation between the


most-rated movies
Classification Algorithms: K-Nearest
Neighbors Sorting the data by correlation

Classification Algorithms: Decision Tree


Filtering out movies
Classification Algorithms: Logistic
regression
Sorting values

Clustering
Repeating the process for
another movie
Recommender System

Conclusion
Recommender system

Recommender System in python


Implementation step 13

Sorting by Correlation
Introduction to Machine Learning

Implementing ML Algorithms in Python


Sorting the most-rated movies

Simple Linear Regression


Grab the ratings for two movies

Multiple Linear Regression Correlation between the


most-rated movies
Classification Algorithms: K-Nearest
Neighbors Sorting the data by correlation

Classification Algorithms: Decision Tree


Filtering out movies

Classification Algorithms: Logistic


regression
Sorting values

Clustering
Repeating the process for
another movie
Recommender System

Conclusion
Recommender system

Recommender System in python


Implementation step 14
Filter out the movies having less than 100 reviews
Introduction to Machine Learning

Implementing ML Algorithms in Python


Sorting the most-rated movies

Simple Linear Regression


Grab the ratings for two movies

Multiple Linear Regression Correlation between the


most-rated movies
Classification Algorithms: K-Nearest
Neighbors Sorting the data by correlation

Classification Algorithms: Decision Tree


Filtering out movies

Classification Algorithms: Logistic


regression
Sorting values

Clustering
Repeating the process for
another movie
Recommender System

Conclusion
Recommender system

Recommender System in python


Implementation step 15
Finally Filter out the titles to make sense
Introduction to Machine Learning

Implementing ML Algorithms in Python


Sorting the most-rated movies
Simple Linear Regression
Grab the ratings for two movies

Multiple Linear Regression


Correlation between the
most-rated movies
Classification Algorithms: K-Nearest
Neighbors
Sorting the data by correlation
Classification Algorithms: Decision Tree
Filtering out movies
Classification Algorithms: Logistic
regression
Sorting values
Clustering
Repeating the process for
another movie
Recommender System

Conclusion
Recommender system

Recommender System in python


Implementation step 16
Doing same for the movie Liar Liar (1997) (Implementation step 11-15)
Quiz Time

Why are recommendation engines becoming popular?

A) Users have less time, more options and face an information


overload
B) It is mandatory to have recommendation engine as per telecom
rules
C) It is better to recommend than ask user to search on cell phones
D) Users don't know what they want
Quiz Time

Why are recommendation engines becoming popular?

A) Users have less time, more options and face an information


overload
B) It is mandatory to have recommendation engine as per telecom
rules
C) It is better to recommend than ask user to search on cell phones
D) Users don't know what they want
Congratulations!

Thank You!

You might also like