SlideShare a Scribd company logo
Machine
Learning Basics
An Introduction
Surviving the Titanic
Suppose, you have to build a model
to predict how many people survived
the Titanic shipwreck
Surviving the Titanic
Suppose, you have to build a model
to predict how many people survived
the Titanic shipwreck
Surviving the Titanic
• ID
• Survived
• Class
• Name
• Sex
• Age
• Siblings
• Parents/children abroad
• Ticket
• Fare
• Cabin
• Place of Embarkment
Teaching the model with the
passenger dataset
Dropping the non-essential
components of the dataset
Determining the survival of
passengers and evaluating the
model
Agenda
What is Supervised Learning?
What is Classification? What are some of its solutions?
What is Logistic Regression?
Comparing Linear and Logistic Regression
Logistic Regression applications
Use Case – Predicting the number in an image
What is Supervised Learning?
What is Supervised Learning?
That’s an
apple!
apple
Teacher teaches child Child recognizes an apple when she sees it again
A model is able to make predictions based on past data
Where does Logistic Regression fit it?
Machine Learning
Supervised Learning Unsupervised Learning
AssociationClusteringClassification Regression
The systems predicts future outcomes based on training from past input
Solutions to Classification
A few Classification Solutions
A B
We take decisions using a tree structure. Each
branch node represents a choice, and leaf node
represents a decision
Decision Trees
A few Classification Solutions
A B
Decision Trees
We take decisions using a tree structure. Each
branch node represents a choice, and leaf node
represents a decision
It helps determine what the given object is, based on
its similarity to the objects it is compared toK=3
K=7
K-Nearest Neighbor
It helps determine what the given object is, based on
its similarity to the objects it is compared toK=3
K=7
K-Nearest Neighbor
Decision Trees
A few Classification Solutions
A B
We determine the probability of an event occurring
with the help of a tree structure
A dataset with one or more independent variables is
used to determine binary output of the dependent
variable
Logistic Regression
What is Logistic Regression?
What is Logistic Regression?
Imagine it’s been a few years since
you serviced your car.
One day you wonder…
What is Logistic Regression?
It is a classification algorithm, used to predict binary outcomes for a given set of independent
variables. The dependent variable’s outcome is discrete.
Regression model created based on other
users’ experience
0.60
0.20
0.40
0.80
1.00
1 2 3 4 5 6
Years since service
Probabilityofbreakdown
How long until the
car breaks down?
You provide years since
last service
What is Logistic Regression?
Probability>0.50
Value rounded off to
1 : The car will
breakdown
Probability<0.50
Value rounded off to 0:
The car will not
breakdown
Here, the threshold
value 0.50 indicates
that the car is more
likely to breakdown
after 3.5 years of
usage
Model makes predictions
0.60
0.20
0.40
0.80
1.00
1 2 3 4 5 6
Years since last service
Probabilityofbreakdown
0.50
0.29
0.90
Threshold Value
What is Linear Regression?
Linear Regression
It is a statistical method that helps find the relationship between an independent and dependent variable,
both of which are continuous
He performed
well in the last
quarter. How
much raise
should he get?
Linear Regression
41 2 3 5
5
10
15
20
25
Employee rating
Salaryhike
Collection of ratings and corresponding
hikes Linear Regression is performed on data
The management provides the
corresponding salary hike
Employee rating
Linear and Logistic Regression
Here’s the graph of how linear
regression would be, for a given
scenario
x
y
Linear and Logistic Regression
What if you wanted to know whether the
employee would get a promotion or not
based on their rating
41 2 3 5
0 =No
1=Yes
Employee rating
Probabilityofgettinga
promotion
Linear and Logistic Regression
This graph would not be able to
make such a prediction. So we clip
the line at 0 and 1.
41 2 3 5
Employee rating
0 =No
1=Yes
Probabilityofgettinga
promotion
Linear and Logistic Regression
So, how did this… …become this?
41 2 3 5
Employee rating
41 2 3 5
Employee rating
0 =No
1=Yes
Probabilityofgettinga
promotion
0 =No
1=Yes
Probabilityofgettinga
promotion
The Math behind Logistic Regression
To understand Logistic Regression, let’s talk
about the odds of success
Odds (𝜃) =
Probability of an
event happening
Probability of an
event not
happening
or 𝜃 =
𝑝
1 − 𝑝
The values of odds range from 0 to ∞
The values of probability change from 0 to 1
The Math behind Logistic Regression
Type equation here.
Take the equation of the straight line
𝛽0
x
y
Here, 𝛽0 is the y-intercept
𝛽1 is the slope of the line
x is the value of the x co-ordinate
y is the value of the prediction
The equation would be: 𝑦 = 𝛽0 + 𝛽1 𝑥
The Math behind Logistic Regression
Type equation here.
Now, we predict the odds of success
e𝑙𝑛
𝑝 𝑥
1 − 𝑝 𝑥
= e 𝛽0+𝛽1 𝑥
log
𝑝 𝑥
1−𝑃 𝑥
= 𝛽0 + 𝛽1 𝑥
Exponentiating both sides:
𝑝 𝑥
1 − 𝑝 𝑥
= e 𝛽0+𝛽1 𝑥
Let Y = e 𝛽0+𝛽1 𝑥
Then
𝑝 𝑥
1−𝑝 𝑥
= Y
𝑝 𝑥 = 𝑌 1 − 𝑝 𝑥
𝑝 𝑥 = 𝑌 − 𝑌 𝑝 𝑥
𝑝 𝑥 + 𝑌 𝑝 𝑥 = 𝑌
𝑝 𝑥 1 + 𝑌 = 𝑌
𝑝 𝑥 =
𝑌
1 + 𝑌
𝑝 𝑥 =
e 𝛽0+𝛽1 𝑥
1 + e 𝛽0+𝛽1 𝑥
The equation of a sigmoid function:
𝑝 𝑥 =
e 𝛽0+𝛽1 𝑥
1 + e 𝛽0+𝛽1 𝑥
𝑝 𝑥 =
1
1 + e−(𝛽0+𝛽1 𝑥)
The Math behind Logistic Regression
Type equation here.
Now, we predict the odds of success
e𝑙𝑛
𝑝 𝑥
1 − 𝑝 𝑥
= e 𝛽0+𝛽1 𝑥
log
𝑝 𝑥
1−𝑃 𝑥
= 𝛽0 + 𝛽1 𝑥
Exponentiating both sides:
𝑝 𝑥
1 − 𝑝 𝑥
= e 𝛽0+𝛽1 𝑥
Let Y = e 𝛽0+𝛽1 𝑥
Then
𝑝 𝑥
1−𝑝 𝑥
= Y
𝑝 𝑥 = 𝑌 1 − 𝑝 𝑥
𝑝 𝑥 = 𝑌 − 𝑌 𝑝 𝑥
𝑝 𝑥 + 𝑌 𝑝 𝑥 = 𝑌
𝑝 𝑥 1 + 𝑌 = 𝑌
𝑝 𝑥 =
𝑌
1 + 𝑌
𝑝 𝑥 =
e 𝛽0+𝛽1 𝑥
1 + e 𝛽0+𝛽1 𝑥
The equation of a sigmoid function:
𝑝 𝑥 =
e 𝛽0+𝛽1 𝑥
1 + e 𝛽0+𝛽1 𝑥
𝑝 𝑥 =
1
1 + e−(𝛽0+𝛽1 𝑥)
41 2 3 5
0
0.25
0.50
0.75
1
Employee rating
Probabilityofgettinga
promotion
A sigmoid curve is obtained!
Comparing Linear and Logistic
Regression
How is Linear and Logistic Regression different?
Linear Regression Logistic Regression
• Used to solve Regression
Problems
How is Linear and Logistic Regression different?
Linear Regression Logistic Regression
• Used to solve Classification
Problems
• Used to solve Regression
Problems
How is Linear and Logistic Regression different?
Linear Regression Logistic Regression
• Used to solve Classification
Problems
• Used to solve Regression
Problems
• The response variables are
continuous in nature
How is Linear and Logistic Regression different?
Linear Regression Logistic Regression
• Used to solve Classification
Problems
• The response variable is
categorical in nature
• Used to solve Regression
Problems
• The response variables are
continuous in nature
How is Linear and Logistic Regression different?
Linear Regression Logistic Regression
• Used to solve Classification
Problems
• The response variable is
categorical in nature
• Used to solve Regression
Problems
• The response variables are
continuous in nature
• It helps estimate the dependent
variable when there is a change
in the independent variable.
How is Linear and Logistic Regression different?
Linear Regression Logistic Regression
• Used to solve Classification
Problems
• The response variable is
categorical in nature
• It helps calculate the possibility
of a particular event taking
place.
• Used to solve Regression
Problems
• The response variables are
continuous in nature
• It helps estimate the dependent
variable when there is a change
in the independent variable.
How is Linear and Logistic Regression different?
Linear Regression Logistic Regression
• Used to solve Classification
Problems
• The response variable is
categorical in nature
• It helps calculate the possibility
of a particular event taking
place.
• Used to solve Regression
Problems
• The response variables are
continuous in nature
• It helps estimate the dependent
variable when there is a change
in the independent variable.
• Is a straight line.
How is Linear and Logistic Regression different?
Linear Regression Logistic Regression
• Used to solve Classification
Problems
• The response variable is
categorical in nature
• It helps calculate the possibility
of a particular event taking
place.
• An S-curve. (S = Sigmoid)
• Used to solve Regression
Problems
• The response variables are
continuous in nature
• It helps estimate the dependent
variable when there is a change
in the independent variable.
• Is a straight line.
Logistic Regression Applications
Weather Prediction
Helps determine the kind of weather that
can be expected
Identifies the different components
that are present in the image, and
helps categorize them
Logistic Regression Applications
Humans Animals Vehicles
Image Categorization
Determines the possibility of patient
survival, taking age, ISS and RTS into
consideration
Logistic Regression Applications
Healthcare (TRISS)
Patient survival %
Revised
Trauma Score
Injury Severity
Score
Age
Use Case – Predicting numbers in
images
Use Case – Predicting numbers
Can you guess
what number I am? Are you a 3? 4?
I don’t know!
8x8 image
Use Case – Predicting numbers
Dividing the data set
Training
set
Test set
The model being trained
Model identifies number in
images
Test set applied
A number 4
A number 1
Use Case – Implementation
Importing libraries and their associated methods
Determining the total number of images and labels
Use Case – Implementation
Displaying some of the images and labels
Use Case – Implementation
Dividing dataset into Training and Test set
Use Case – Implementation
Import the Logistic Regression model
Making an instance of the model and training it
Predicting the output of the first element of the test set
Predicting the output of the first 10 elements of the test set
Use Case – Implementation
Predicting for the entire dataset
Determining the accuracy of the model
Representing the confusion matrix in a heat map
Use Case – Implementation
Accurately predicting the image to
contain a zero
Inaccurately predicting the image to
contain a seven
Use Case – Implementation
Presenting predictions and actual output
Use Case – Predicting numbers
Dividing the data set
Training
set
Test
set
The model being trained Model identifies number in
images
Test set applied
A number 4
A number 2
Here’s What You’ve Learnt so Far
So what’s
your next step?

More Related Content

PDF
Logistic Regression in Python | Logistic Regression Example | Machine Learnin...
Edureka!
 
ODP
Machine Learning With Logistic Regression
Knoldus Inc.
 
PDF
Logistic regression : Use Case | Background | Advantages | Disadvantages
Rajat Sharma
 
PDF
Linear Regression vs Logistic Regression | Edureka
Edureka!
 
PPTX
Linear Regression Analysis | Linear Regression in Python | Machine Learning A...
Simplilearn
 
PPTX
Ml3 logistic regression-and_classification_error_metrics
ankit_ppt
 
PPTX
Logistic Regression power point presentation.pptx
harshasawa2003
 
PDF
Linear Regression Algorithm | Linear Regression in Python | Machine Learning ...
Edureka!
 
Logistic Regression in Python | Logistic Regression Example | Machine Learnin...
Edureka!
 
Machine Learning With Logistic Regression
Knoldus Inc.
 
Logistic regression : Use Case | Background | Advantages | Disadvantages
Rajat Sharma
 
Linear Regression vs Logistic Regression | Edureka
Edureka!
 
Linear Regression Analysis | Linear Regression in Python | Machine Learning A...
Simplilearn
 
Ml3 logistic regression-and_classification_error_metrics
ankit_ppt
 
Logistic Regression power point presentation.pptx
harshasawa2003
 
Linear Regression Algorithm | Linear Regression in Python | Machine Learning ...
Edureka!
 

What's hot (20)

PPTX
Support vector machines (svm)
Sharayu Patil
 
PDF
Logistic regression
Venkata Reddy Konasani
 
PPTX
ML - Simple Linear Regression
Andrew Ferlitsch
 
PPTX
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
Simplilearn
 
PPTX
Logistic regression
YashwantGahlot1
 
PPTX
Support Vector Machine - How Support Vector Machine works | SVM in Machine Le...
Simplilearn
 
PPTX
Introduction to Linear Discriminant Analysis
Jaclyn Kokx
 
PPTX
Naive Bayes Classifier | Naive Bayes Algorithm | Naive Bayes Classifier With ...
Simplilearn
 
PPTX
Support Vector Machine ppt presentation
AyanaRukasar
 
PPT
Association rule mining
Acad
 
PDF
Dimensionality Reduction
mrizwan969
 
PPT
Bayes Classification
sathish sak
 
PDF
Dimensionality Reduction
Saad Elbeleidy
 
PDF
Feature Engineering
HJ van Veen
 
PDF
Linear regression
MartinHogg9
 
PDF
Classification Based Machine Learning Algorithms
Md. Main Uddin Rony
 
PPTX
KNN Algorithm - How KNN Algorithm Works With Example | Data Science For Begin...
Simplilearn
 
PDF
The Data Science Process
Vishal Patel
 
Support vector machines (svm)
Sharayu Patil
 
Logistic regression
Venkata Reddy Konasani
 
ML - Simple Linear Regression
Andrew Ferlitsch
 
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
Simplilearn
 
Logistic regression
YashwantGahlot1
 
Support Vector Machine - How Support Vector Machine works | SVM in Machine Le...
Simplilearn
 
Introduction to Linear Discriminant Analysis
Jaclyn Kokx
 
Naive Bayes Classifier | Naive Bayes Algorithm | Naive Bayes Classifier With ...
Simplilearn
 
Support Vector Machine ppt presentation
AyanaRukasar
 
Association rule mining
Acad
 
Dimensionality Reduction
mrizwan969
 
Bayes Classification
sathish sak
 
Dimensionality Reduction
Saad Elbeleidy
 
Feature Engineering
HJ van Veen
 
Linear regression
MartinHogg9
 
Classification Based Machine Learning Algorithms
Md. Main Uddin Rony
 
KNN Algorithm - How KNN Algorithm Works With Example | Data Science For Begin...
Simplilearn
 
The Data Science Process
Vishal Patel
 
Ad

Similar to Logistic Regression | Logistic Regression In Python | Machine Learning Algorithms | Simplilearn (20)

PDF
Module -6.pdf Machine Learning Types and examples
Ramya Nellutla
 
PPTX
Logistic Regression in machine learning ppt
raminder12_kaur
 
PPTX
Supervised Machine Learning Algorithms
engrfarhanhanif
 
PDF
Machine Learning.pdf
University of Sindh
 
PDF
3ml.pdf
MianAdnan27
 
PPTX
Logistic Regression.pptx
Muskaan194530
 
PPTX
lec+5+_part+1 cloud .pptx
samaghorab
 
PPTX
Logistic regression is a data analysis technique that uses mathematics to fin...
Jayashree Sapaliga
 
PPTX
Logistic regression is a data analysis technique that uses mathematics to fin...
Jayashree Sapaliga
 
PDF
Classification Techniques for Machine Learning
rahuljain582793
 
DOCX
Logistic Regression in machine learning.docx
AbhaBansal8
 
PPTX
logistic regression in Data science Presentation
ARUN R S
 
PDF
Logistic regression in Machine Learning
Kuppusamy P
 
PPT
Logistic regression.ppt
BalaChowdappa1
 
PDF
Machine Learning-Lec5.pdf_explain of logistic regression
BeshoyArnest
 
PDF
logisticregression-190726150723.pdf
SuaibDanish
 
PDF
Logistic Regression : classification algorithm
habibaabderrahim1
 
PPTX
Supervised learning - Linear and Logistic Regression( AI, ML)
Rahul Pal
 
PPTX
Linear Regression and Logistic Regression in ML
Kumud Arora
 
PDF
Machine Learning Algorithm - Logistic Regression
Kush Kulshrestha
 
Module -6.pdf Machine Learning Types and examples
Ramya Nellutla
 
Logistic Regression in machine learning ppt
raminder12_kaur
 
Supervised Machine Learning Algorithms
engrfarhanhanif
 
Machine Learning.pdf
University of Sindh
 
3ml.pdf
MianAdnan27
 
Logistic Regression.pptx
Muskaan194530
 
lec+5+_part+1 cloud .pptx
samaghorab
 
Logistic regression is a data analysis technique that uses mathematics to fin...
Jayashree Sapaliga
 
Logistic regression is a data analysis technique that uses mathematics to fin...
Jayashree Sapaliga
 
Classification Techniques for Machine Learning
rahuljain582793
 
Logistic Regression in machine learning.docx
AbhaBansal8
 
logistic regression in Data science Presentation
ARUN R S
 
Logistic regression in Machine Learning
Kuppusamy P
 
Logistic regression.ppt
BalaChowdappa1
 
Machine Learning-Lec5.pdf_explain of logistic regression
BeshoyArnest
 
logisticregression-190726150723.pdf
SuaibDanish
 
Logistic Regression : classification algorithm
habibaabderrahim1
 
Supervised learning - Linear and Logistic Regression( AI, ML)
Rahul Pal
 
Linear Regression and Logistic Regression in ML
Kumud Arora
 
Machine Learning Algorithm - Logistic Regression
Kush Kulshrestha
 
Ad

More from Simplilearn (20)

PPTX
Top 50 Scrum Master Interview Questions | Scrum Master Interview Questions & ...
Simplilearn
 
PPTX
Bagging Vs Boosting In Machine Learning | Ensemble Learning In Machine Learni...
Simplilearn
 
PPTX
Future Of Social Media | Social Media Trends and Strategies 2025 | Instagram ...
Simplilearn
 
PPTX
SQL Query Optimization | SQL Query Optimization Techniques | SQL Basics | SQL...
Simplilearn
 
PPTX
SQL INterview Questions .pTop 45 SQL Interview Questions And Answers In 2025 ...
Simplilearn
 
PPTX
How To Start Influencer Marketing Business | Influencer Marketing For Beginne...
Simplilearn
 
PPTX
Cyber Security Roadmap 2025 | How To Become Cyber Security Engineer In 2025 |...
Simplilearn
 
PPTX
How To Become An AI And ML Engineer In 2025 | AI Engineer Roadmap | AI ML Car...
Simplilearn
 
PPTX
What Is GitHub Copilot? | How To Use GitHub Copilot? | How does GitHub Copilo...
Simplilearn
 
PPTX
Top 10 Data Analyst Certification For 2025 | Best Data Analyst Certification ...
Simplilearn
 
PPTX
Complete Data Science Roadmap For 2025 | Data Scientist Roadmap For Beginners...
Simplilearn
 
PPTX
Top 7 High Paying AI Certifications Courses For 2025 | Best AI Certifications...
Simplilearn
 
PPTX
Data Cleaning In Data Mining | Step by Step Data Cleaning Process | Data Clea...
Simplilearn
 
PPTX
Top 10 Data Analyst Projects For 2025 | Data Analyst Projects | Data Analysis...
Simplilearn
 
PPTX
AI Engineer Roadmap 2025 | AI Engineer Roadmap For Beginners | AI Engineer Ca...
Simplilearn
 
PPTX
Machine Learning Roadmap 2025 | Machine Learning Engineer Roadmap For Beginne...
Simplilearn
 
PPTX
Kotter's 8-Step Change Model Explained | Kotter's Change Management Model | S...
Simplilearn
 
PPTX
Gen AI Engineer Roadmap For 2025 | How To Become Gen AI Engineer In 2025 | Si...
Simplilearn
 
PPTX
Top 10 Data Analyst Certification For 2025 | Best Data Analyst Certification ...
Simplilearn
 
PPTX
Complete Data Science Roadmap For 2025 | Data Scientist Roadmap For Beginners...
Simplilearn
 
Top 50 Scrum Master Interview Questions | Scrum Master Interview Questions & ...
Simplilearn
 
Bagging Vs Boosting In Machine Learning | Ensemble Learning In Machine Learni...
Simplilearn
 
Future Of Social Media | Social Media Trends and Strategies 2025 | Instagram ...
Simplilearn
 
SQL Query Optimization | SQL Query Optimization Techniques | SQL Basics | SQL...
Simplilearn
 
SQL INterview Questions .pTop 45 SQL Interview Questions And Answers In 2025 ...
Simplilearn
 
How To Start Influencer Marketing Business | Influencer Marketing For Beginne...
Simplilearn
 
Cyber Security Roadmap 2025 | How To Become Cyber Security Engineer In 2025 |...
Simplilearn
 
How To Become An AI And ML Engineer In 2025 | AI Engineer Roadmap | AI ML Car...
Simplilearn
 
What Is GitHub Copilot? | How To Use GitHub Copilot? | How does GitHub Copilo...
Simplilearn
 
Top 10 Data Analyst Certification For 2025 | Best Data Analyst Certification ...
Simplilearn
 
Complete Data Science Roadmap For 2025 | Data Scientist Roadmap For Beginners...
Simplilearn
 
Top 7 High Paying AI Certifications Courses For 2025 | Best AI Certifications...
Simplilearn
 
Data Cleaning In Data Mining | Step by Step Data Cleaning Process | Data Clea...
Simplilearn
 
Top 10 Data Analyst Projects For 2025 | Data Analyst Projects | Data Analysis...
Simplilearn
 
AI Engineer Roadmap 2025 | AI Engineer Roadmap For Beginners | AI Engineer Ca...
Simplilearn
 
Machine Learning Roadmap 2025 | Machine Learning Engineer Roadmap For Beginne...
Simplilearn
 
Kotter's 8-Step Change Model Explained | Kotter's Change Management Model | S...
Simplilearn
 
Gen AI Engineer Roadmap For 2025 | How To Become Gen AI Engineer In 2025 | Si...
Simplilearn
 
Top 10 Data Analyst Certification For 2025 | Best Data Analyst Certification ...
Simplilearn
 
Complete Data Science Roadmap For 2025 | Data Scientist Roadmap For Beginners...
Simplilearn
 

Recently uploaded (20)

PDF
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
DOCX
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
PPTX
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
PPTX
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
PDF
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
PPTX
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
PPTX
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
PPTX
Care of patients with elImination deviation.pptx
AneetaSharma15
 
PPTX
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
PDF
UTS Health Student Promotional Representative_Position Description.pdf
Faculty of Health, University of Technology Sydney
 
PPTX
Autodock-for-Beginners by Rahul D Jawarkar.pptx
Rahul Jawarkar
 
PPTX
Odoo 18 Sales_ Managing Quotation Validity
Celine George
 
PDF
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
PPTX
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
DOCX
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
PDF
Health-The-Ultimate-Treasure (1).pdf/8th class science curiosity /samyans edu...
Sandeep Swamy
 
PDF
Types of Literary Text: Poetry and Prose
kaelandreabibit
 
PDF
The Picture of Dorian Gray summary and depiction
opaliyahemel
 
Review of Related Literature & Studies.pdf
Thelma Villaflores
 
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
How to Close Subscription in Odoo 18 - Odoo Slides
Celine George
 
Tips Management in Odoo 18 POS - Odoo Slides
Celine George
 
What is CFA?? Complete Guide to the Chartered Financial Analyst Program
sp4989653
 
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
Care of patients with elImination deviation.pptx
AneetaSharma15
 
PPTs-The Rise of Empiresghhhhhhhh (1).pptx
academysrusti114
 
UTS Health Student Promotional Representative_Position Description.pdf
Faculty of Health, University of Technology Sydney
 
Autodock-for-Beginners by Rahul D Jawarkar.pptx
Rahul Jawarkar
 
Odoo 18 Sales_ Managing Quotation Validity
Celine George
 
The Minister of Tourism, Culture and Creative Arts, Abla Dzifa Gomashie has e...
nservice241
 
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
Action Plan_ARAL PROGRAM_ STAND ALONE SHS.docx
Levenmartlacuna1
 
Health-The-Ultimate-Treasure (1).pdf/8th class science curiosity /samyans edu...
Sandeep Swamy
 
Types of Literary Text: Poetry and Prose
kaelandreabibit
 
The Picture of Dorian Gray summary and depiction
opaliyahemel
 

Logistic Regression | Logistic Regression In Python | Machine Learning Algorithms | Simplilearn

  • 2. Surviving the Titanic Suppose, you have to build a model to predict how many people survived the Titanic shipwreck
  • 3. Surviving the Titanic Suppose, you have to build a model to predict how many people survived the Titanic shipwreck
  • 4. Surviving the Titanic • ID • Survived • Class • Name • Sex • Age • Siblings • Parents/children abroad • Ticket • Fare • Cabin • Place of Embarkment Teaching the model with the passenger dataset Dropping the non-essential components of the dataset Determining the survival of passengers and evaluating the model
  • 5. Agenda What is Supervised Learning? What is Classification? What are some of its solutions? What is Logistic Regression? Comparing Linear and Logistic Regression Logistic Regression applications Use Case – Predicting the number in an image
  • 6. What is Supervised Learning?
  • 7. What is Supervised Learning? That’s an apple! apple Teacher teaches child Child recognizes an apple when she sees it again A model is able to make predictions based on past data
  • 8. Where does Logistic Regression fit it? Machine Learning Supervised Learning Unsupervised Learning AssociationClusteringClassification Regression The systems predicts future outcomes based on training from past input
  • 10. A few Classification Solutions A B We take decisions using a tree structure. Each branch node represents a choice, and leaf node represents a decision Decision Trees
  • 11. A few Classification Solutions A B Decision Trees We take decisions using a tree structure. Each branch node represents a choice, and leaf node represents a decision It helps determine what the given object is, based on its similarity to the objects it is compared toK=3 K=7 K-Nearest Neighbor
  • 12. It helps determine what the given object is, based on its similarity to the objects it is compared toK=3 K=7 K-Nearest Neighbor Decision Trees A few Classification Solutions A B We determine the probability of an event occurring with the help of a tree structure A dataset with one or more independent variables is used to determine binary output of the dependent variable Logistic Regression
  • 13. What is Logistic Regression?
  • 14. What is Logistic Regression? Imagine it’s been a few years since you serviced your car. One day you wonder…
  • 15. What is Logistic Regression? It is a classification algorithm, used to predict binary outcomes for a given set of independent variables. The dependent variable’s outcome is discrete. Regression model created based on other users’ experience 0.60 0.20 0.40 0.80 1.00 1 2 3 4 5 6 Years since service Probabilityofbreakdown How long until the car breaks down? You provide years since last service
  • 16. What is Logistic Regression? Probability>0.50 Value rounded off to 1 : The car will breakdown Probability<0.50 Value rounded off to 0: The car will not breakdown Here, the threshold value 0.50 indicates that the car is more likely to breakdown after 3.5 years of usage Model makes predictions 0.60 0.20 0.40 0.80 1.00 1 2 3 4 5 6 Years since last service Probabilityofbreakdown 0.50 0.29 0.90 Threshold Value
  • 17. What is Linear Regression?
  • 18. Linear Regression It is a statistical method that helps find the relationship between an independent and dependent variable, both of which are continuous He performed well in the last quarter. How much raise should he get?
  • 19. Linear Regression 41 2 3 5 5 10 15 20 25 Employee rating Salaryhike Collection of ratings and corresponding hikes Linear Regression is performed on data The management provides the corresponding salary hike Employee rating
  • 20. Linear and Logistic Regression Here’s the graph of how linear regression would be, for a given scenario x y
  • 21. Linear and Logistic Regression What if you wanted to know whether the employee would get a promotion or not based on their rating 41 2 3 5 0 =No 1=Yes Employee rating Probabilityofgettinga promotion
  • 22. Linear and Logistic Regression This graph would not be able to make such a prediction. So we clip the line at 0 and 1. 41 2 3 5 Employee rating 0 =No 1=Yes Probabilityofgettinga promotion
  • 23. Linear and Logistic Regression So, how did this… …become this? 41 2 3 5 Employee rating 41 2 3 5 Employee rating 0 =No 1=Yes Probabilityofgettinga promotion 0 =No 1=Yes Probabilityofgettinga promotion
  • 24. The Math behind Logistic Regression To understand Logistic Regression, let’s talk about the odds of success Odds (𝜃) = Probability of an event happening Probability of an event not happening or 𝜃 = 𝑝 1 − 𝑝 The values of odds range from 0 to ∞ The values of probability change from 0 to 1
  • 25. The Math behind Logistic Regression Type equation here. Take the equation of the straight line 𝛽0 x y Here, 𝛽0 is the y-intercept 𝛽1 is the slope of the line x is the value of the x co-ordinate y is the value of the prediction The equation would be: 𝑦 = 𝛽0 + 𝛽1 𝑥
  • 26. The Math behind Logistic Regression Type equation here. Now, we predict the odds of success e𝑙𝑛 𝑝 𝑥 1 − 𝑝 𝑥 = e 𝛽0+𝛽1 𝑥 log 𝑝 𝑥 1−𝑃 𝑥 = 𝛽0 + 𝛽1 𝑥 Exponentiating both sides: 𝑝 𝑥 1 − 𝑝 𝑥 = e 𝛽0+𝛽1 𝑥 Let Y = e 𝛽0+𝛽1 𝑥 Then 𝑝 𝑥 1−𝑝 𝑥 = Y 𝑝 𝑥 = 𝑌 1 − 𝑝 𝑥 𝑝 𝑥 = 𝑌 − 𝑌 𝑝 𝑥 𝑝 𝑥 + 𝑌 𝑝 𝑥 = 𝑌 𝑝 𝑥 1 + 𝑌 = 𝑌 𝑝 𝑥 = 𝑌 1 + 𝑌 𝑝 𝑥 = e 𝛽0+𝛽1 𝑥 1 + e 𝛽0+𝛽1 𝑥 The equation of a sigmoid function: 𝑝 𝑥 = e 𝛽0+𝛽1 𝑥 1 + e 𝛽0+𝛽1 𝑥 𝑝 𝑥 = 1 1 + e−(𝛽0+𝛽1 𝑥)
  • 27. The Math behind Logistic Regression Type equation here. Now, we predict the odds of success e𝑙𝑛 𝑝 𝑥 1 − 𝑝 𝑥 = e 𝛽0+𝛽1 𝑥 log 𝑝 𝑥 1−𝑃 𝑥 = 𝛽0 + 𝛽1 𝑥 Exponentiating both sides: 𝑝 𝑥 1 − 𝑝 𝑥 = e 𝛽0+𝛽1 𝑥 Let Y = e 𝛽0+𝛽1 𝑥 Then 𝑝 𝑥 1−𝑝 𝑥 = Y 𝑝 𝑥 = 𝑌 1 − 𝑝 𝑥 𝑝 𝑥 = 𝑌 − 𝑌 𝑝 𝑥 𝑝 𝑥 + 𝑌 𝑝 𝑥 = 𝑌 𝑝 𝑥 1 + 𝑌 = 𝑌 𝑝 𝑥 = 𝑌 1 + 𝑌 𝑝 𝑥 = e 𝛽0+𝛽1 𝑥 1 + e 𝛽0+𝛽1 𝑥 The equation of a sigmoid function: 𝑝 𝑥 = e 𝛽0+𝛽1 𝑥 1 + e 𝛽0+𝛽1 𝑥 𝑝 𝑥 = 1 1 + e−(𝛽0+𝛽1 𝑥) 41 2 3 5 0 0.25 0.50 0.75 1 Employee rating Probabilityofgettinga promotion A sigmoid curve is obtained!
  • 28. Comparing Linear and Logistic Regression
  • 29. How is Linear and Logistic Regression different? Linear Regression Logistic Regression • Used to solve Regression Problems
  • 30. How is Linear and Logistic Regression different? Linear Regression Logistic Regression • Used to solve Classification Problems • Used to solve Regression Problems
  • 31. How is Linear and Logistic Regression different? Linear Regression Logistic Regression • Used to solve Classification Problems • Used to solve Regression Problems • The response variables are continuous in nature
  • 32. How is Linear and Logistic Regression different? Linear Regression Logistic Regression • Used to solve Classification Problems • The response variable is categorical in nature • Used to solve Regression Problems • The response variables are continuous in nature
  • 33. How is Linear and Logistic Regression different? Linear Regression Logistic Regression • Used to solve Classification Problems • The response variable is categorical in nature • Used to solve Regression Problems • The response variables are continuous in nature • It helps estimate the dependent variable when there is a change in the independent variable.
  • 34. How is Linear and Logistic Regression different? Linear Regression Logistic Regression • Used to solve Classification Problems • The response variable is categorical in nature • It helps calculate the possibility of a particular event taking place. • Used to solve Regression Problems • The response variables are continuous in nature • It helps estimate the dependent variable when there is a change in the independent variable.
  • 35. How is Linear and Logistic Regression different? Linear Regression Logistic Regression • Used to solve Classification Problems • The response variable is categorical in nature • It helps calculate the possibility of a particular event taking place. • Used to solve Regression Problems • The response variables are continuous in nature • It helps estimate the dependent variable when there is a change in the independent variable. • Is a straight line.
  • 36. How is Linear and Logistic Regression different? Linear Regression Logistic Regression • Used to solve Classification Problems • The response variable is categorical in nature • It helps calculate the possibility of a particular event taking place. • An S-curve. (S = Sigmoid) • Used to solve Regression Problems • The response variables are continuous in nature • It helps estimate the dependent variable when there is a change in the independent variable. • Is a straight line.
  • 37. Logistic Regression Applications Weather Prediction Helps determine the kind of weather that can be expected
  • 38. Identifies the different components that are present in the image, and helps categorize them Logistic Regression Applications Humans Animals Vehicles Image Categorization
  • 39. Determines the possibility of patient survival, taking age, ISS and RTS into consideration Logistic Regression Applications Healthcare (TRISS) Patient survival % Revised Trauma Score Injury Severity Score Age
  • 40. Use Case – Predicting numbers in images
  • 41. Use Case – Predicting numbers Can you guess what number I am? Are you a 3? 4? I don’t know! 8x8 image
  • 42. Use Case – Predicting numbers Dividing the data set Training set Test set The model being trained Model identifies number in images Test set applied A number 4 A number 1
  • 43. Use Case – Implementation Importing libraries and their associated methods Determining the total number of images and labels
  • 44. Use Case – Implementation Displaying some of the images and labels
  • 45. Use Case – Implementation Dividing dataset into Training and Test set
  • 46. Use Case – Implementation Import the Logistic Regression model Making an instance of the model and training it Predicting the output of the first element of the test set Predicting the output of the first 10 elements of the test set
  • 47. Use Case – Implementation Predicting for the entire dataset Determining the accuracy of the model Representing the confusion matrix in a heat map
  • 48. Use Case – Implementation Accurately predicting the image to contain a zero Inaccurately predicting the image to contain a seven
  • 49. Use Case – Implementation Presenting predictions and actual output
  • 50. Use Case – Predicting numbers Dividing the data set Training set Test set The model being trained Model identifies number in images Test set applied A number 4 A number 2
  • 51. Here’s What You’ve Learnt so Far

Editor's Notes