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

What's hot (20)

ODP
NAIVE BAYES CLASSIFIER
Knoldus Inc.
 
PDF
Logistic regression in Machine Learning
Kuppusamy P
 
PDF
Linear regression
MartinHogg9
 
PPTX
Support Vector Machine - How Support Vector Machine works | SVM in Machine Le...
Simplilearn
 
PPTX
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
Simplilearn
 
PPTX
Machine Learning Tutorial | Machine Learning Basics | Machine Learning Algori...
Simplilearn
 
PDF
Introduction to Machine Learning Classifiers
Functional Imperative
 
PPTX
Machine learning session4(linear regression)
Abhimanyu Dwivedi
 
PPTX
Backpropagation And Gradient Descent In Neural Networks | Neural Network Tuto...
Simplilearn
 
PDF
Classification Based Machine Learning Algorithms
Md. Main Uddin Rony
 
PDF
03 Machine Learning Linear Algebra
Andres Mendez-Vazquez
 
PPTX
Unit 2 unsupervised learning.pptx
Dr.Shweta
 
PPTX
Naïve Bayes Classifier Algorithm.pptx
Shubham Jaybhaye
 
PPTX
Random forest algorithm
Rashid Ansari
 
PPTX
Data mining: Classification and prediction
DataminingTools Inc
 
PPTX
Classification and Regression
Megha Sharma
 
PPT
K mean-clustering
Afzaal Subhani
 
PPTX
Support vector machine
zekeLabs Technologies
 
PPTX
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
Simplilearn
 
PPTX
Types of Machine Learning
Samra Shahzadi
 
NAIVE BAYES CLASSIFIER
Knoldus Inc.
 
Logistic regression in Machine Learning
Kuppusamy P
 
Linear regression
MartinHogg9
 
Support Vector Machine - How Support Vector Machine works | SVM in Machine Le...
Simplilearn
 
Supervised and Unsupervised Learning In Machine Learning | Machine Learning T...
Simplilearn
 
Machine Learning Tutorial | Machine Learning Basics | Machine Learning Algori...
Simplilearn
 
Introduction to Machine Learning Classifiers
Functional Imperative
 
Machine learning session4(linear regression)
Abhimanyu Dwivedi
 
Backpropagation And Gradient Descent In Neural Networks | Neural Network Tuto...
Simplilearn
 
Classification Based Machine Learning Algorithms
Md. Main Uddin Rony
 
03 Machine Learning Linear Algebra
Andres Mendez-Vazquez
 
Unit 2 unsupervised learning.pptx
Dr.Shweta
 
Naïve Bayes Classifier Algorithm.pptx
Shubham Jaybhaye
 
Random forest algorithm
Rashid Ansari
 
Data mining: Classification and prediction
DataminingTools Inc
 
Classification and Regression
Megha Sharma
 
K mean-clustering
Afzaal Subhani
 
Support vector machine
zekeLabs Technologies
 
K Means Clustering Algorithm | K Means Clustering Example | Machine Learning ...
Simplilearn
 
Types of Machine Learning
Samra Shahzadi
 

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

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
 
PPT
Logistic regression.ppt
BalaChowdappa1
 
PDF
Machine Learning-Lec5.pdf_explain of logistic regression
BeshoyArnest
 
PDF
logisticregression-190726150723.pdf
SuaibDanish
 
PDF
Logistic regression : Use Case | Background | Advantages | Disadvantages
Rajat Sharma
 
PPTX
Logistic Regression power point presentation.pptx
harshasawa2003
 
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
 
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.ppt
BalaChowdappa1
 
Machine Learning-Lec5.pdf_explain of logistic regression
BeshoyArnest
 
logisticregression-190726150723.pdf
SuaibDanish
 
Logistic regression : Use Case | Background | Advantages | Disadvantages
Rajat Sharma
 
Logistic Regression power point presentation.pptx
harshasawa2003
 
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
 
Ad

Recently uploaded (20)

PPTX
Light Reflection and Refraction- Activities - Class X Science
SONU ACADEMY
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PDF
Mahidol_Change_Agent_Note_2025-06-27-29_MUSEF
Tassanee Lerksuthirat
 
PPTX
Difference between write and update in odoo 18
Celine George
 
PPTX
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
PPTX
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
PDF
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
PPTX
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
PPTX
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
PPTX
Controller Request and Response in Odoo18
Celine George
 
PDF
Workbook de Inglés Completo - English Path.pdf
shityouenglishpath
 
PDF
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
PPTX
Introduction to Indian Writing in English
Trushali Dodiya
 
PDF
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PPTX
infertility, types,causes, impact, and management
Ritu480198
 
PDF
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
PPTX
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
PDF
IMPORTANT GUIDELINES FOR M.Sc.ZOOLOGY DISSERTATION
raviralanaresh2
 
PDF
Council of Chalcedon Re-Examined
Smiling Lungs
 
Light Reflection and Refraction- Activities - Class X Science
SONU ACADEMY
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
Mahidol_Change_Agent_Note_2025-06-27-29_MUSEF
Tassanee Lerksuthirat
 
Difference between write and update in odoo 18
Celine George
 
Introduction to Biochemistry & Cellular Foundations.pptx
marvinnbustamante1
 
CATEGORIES OF NURSING PERSONNEL: HOSPITAL & COLLEGE
PRADEEP ABOTHU
 
Governor Josh Stein letter to NC delegation of U.S. House
Mebane Rash
 
care of patient with elimination needs.pptx
Rekhanjali Gupta
 
PPT-Q1-WK-3-ENGLISH Revised Matatag Grade 3.pptx
reijhongidayawan02
 
Controller Request and Response in Odoo18
Celine George
 
Workbook de Inglés Completo - English Path.pdf
shityouenglishpath
 
Week 2 - Irish Natural Heritage Powerpoint.pdf
swainealan
 
Introduction to Indian Writing in English
Trushali Dodiya
 
STATEMENT-BY-THE-HON.-MINISTER-FOR-HEALTH-ON-THE-COVID-19-OUTBREAK-AT-UG_revi...
nservice241
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
infertility, types,causes, impact, and management
Ritu480198
 
Android Programming - Basics of Mobile App, App tools and Android Basics
Kavitha P.V
 
Post Dated Cheque(PDC) Management in Odoo 18
Celine George
 
IMPORTANT GUIDELINES FOR M.Sc.ZOOLOGY DISSERTATION
raviralanaresh2
 
Council of Chalcedon Re-Examined
Smiling Lungs
 

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