SlideShare a Scribd company logo
www.edureka.co/pythonData Science Certification Training
python
www.edureka.co/pythonData Science Certification Training
Topics Covered in Today’s Training
What is Regression?
Logistic regression: What and Why?
Linear Vs Logistic Regression
Use- Cases
Demo
Copyright © 2018, edureka and/or its affiliates. All rights reserved.
What Is Regression
www.edureka.co/pythonData Science Certification Training
What is Regression?
Regression Analysis is a predictive modelling technique
It estimates the relationship between a dependent (target)
and an independent variable(predictor)
Copyright © 2018, edureka and/or its affiliates. All rights reserved.
Logistic Regression:
What And Why
www.edureka.co/pythonData Science Certification Training
Logistic Regression: What And Why?
Logistic Regression produces results in a binary format which is used to predict the outcome of a
categorical dependent variable. So the outcome should be discrete/ categorical such as:
No Code required to implement RPA
No Downtime.
24/7 up and running
Improved Accuracy
Reduced Costs
0 OR 1
Yes OR No
True OR False
High And Low
www.edureka.co/pythonData Science Certification Training
Why Not Linear Regression?
Y-axis
X-axis
0
1
Since our value of Y
will be between 0
and 1, the linear line
has to be clipped at
0 and 1.
www.edureka.co/pythonData Science Certification Training
Why Not Linear Regression?
Y-axis
X-axis
0
1
With this, our resulting
curve cannot be
formulated into a
single formula.
Hence we came up
with Logistic!
www.edureka.co/pythonData Science Certification Training
Logistic Regression Curve
The Sigmoid “S”
Curve
www.edureka.co/pythonData Science Certification Training
The Sigmoid “S”
Curve
With this, the
threshold value
indicates the
probability of winning
or losing
0.5
THRESHOLD VALUE
Logistic Regression Curve
www.edureka.co/pythonData Science Certification Training
The Logistic Regression Equation is derived from the Straight Line Equation
Logistic Regression Equation
Equation of a straight line
Y = C + BIX1 + B2X2 +…. Range is from –(infinity) to (infinity)
www.edureka.co/pythonData Science Certification Training
The Logistic Regression Equation is derived from the Straight Line Equation
Logistic Regression Equation
Equation of a straight line
Y = C + BIX1 + B2X2 +…. Range is from –(infinity) to (infinity)
Let’s try to reduce the Logistic Regression Equation from Straight Line Equation
Y = C + BIX1 + B2X2 +…. In Logistic equation Y can be only from 0 to 1
www.edureka.co/pythonData Science Certification Training
Logistic Regression Equation
Equation of a straight line
Range is from –(infinity) to (infinity)
Let’s try to reduce the Logistic Regression Equation from Straight Line Equation
In Logistic equation Y can be only from 0 to 1
Now , to get the range of Y between 0 and infinity, let’s transform Y
Now, the range is between 0 to infinity
The Logistic Regression Equation is derived from the Straight Line Equation
Y = C + BIX1 + B2X2 +….
Y = C + BIX1 + B2X2 +….
Y= 0 then 0
Y= 1 then infinity
Y
1-Y
www.edureka.co/pythonData Science Certification Training
Logistic Regression Equation
Equation of a straight line
Range is from –(infinity) to (infinity)
Let’s try to reduce the Logistic Regression Equation from Straight Line Equation
In Logistic equation Y can be only from 0 to 1
Now , to get the range of Y between 0 and infinity, let’s transform Y
Now, the range is between 0 to infinity
Let us transform it further, to get range between –(infinity) and (infinity)
log Y
1-Y
Y = C + BIX1 + B2X2 +…. Final Logistic Regression Equation
The Logistic Regression Equation is derived from the Straight Line Equation
Y = C + BIX1 + B2X2 +….
Y = C + BIX1 + B2X2 +….
Y= 0 then 0
Y= 1 then infinity
Y
1-Y
Copyright © 2018, edureka and/or its affiliates. All rights reserved.
Linear
Logistic
www.edureka.co/pythonData Science Certification Training
Linear Vs Logistic Regression
Linear Regression Logistic Regression
Continuous variables1
Solves Regression Problems2
Straight line3
Categorical variables1
Solves Classification Problems2
S-Curve3
Copyright © 2018, edureka and/or its affiliates. All rights reserved.
Logistic Regression:
Use - Cases
www.edureka.co/pythonData Science Certification Training
Logistic Regression: Use - Cases
Weather
Predictions
www.edureka.co/pythonData Science Certification Training
Logistic Regression: Use - Cases
Classification
Problems
www.edureka.co/pythonData Science Certification Training
Logistic Regression: Use - Cases
Determines
Illness
Copyright © 2018, edureka and/or its affiliates. All rights reserved.
Demo
www.edureka.co/pythonData Science Certification Training
1
Titanic Data Analysis
Explore titanic dataset and explore about the people, both those who survived and those who did
not. With today's technology, answering questions through data analysis is now easier than ever.
1
What factors made people more likely to
survive the sinking of the Titanic?
www.edureka.co/pythonData Science Certification Training
Titanic Dataset
www.edureka.co/pythonData Science Certification Training
Implement Logistic Regression
Analyzing Data
1
2
3
4
5
Collecting Data
Train & Test
Data Wrangling
Accuracy Check
www.edureka.co/pythonData Science Certification Training
Implement Logistic Regression
1
2
3
4
5
Collect Data: Import Libraries
www.edureka.co/pythonData Science Certification Training
Implement Logistic Regression
1
2
3
4
5
Analyzing Data
Creating different plot to check
relationship between variables
www.edureka.co/pythonData Science Certification Training
Implement Logistic Regression
1
2
3
4
5
Analyzing Data
Creating different plot to check
relationship between variables
www.edureka.co/pythonData Science Certification Training
Implement Logistic Regression
1
2
3
4
5
Data Wrangling
Clean the data by removing
the Nan values and
unnecessary columns in the
dataset
www.edureka.co/pythonData Science Certification Training
Implement Logistic Regression
1
2
3
4
5
Train & Test Data
Build the model on the train
data and predict the output on
the test data
logistic = LogisticRegression()
logistic.fit(train_X,train_Y)
www.edureka.co/pythonData Science Certification Training
Implement Logistic Regression
1
2
3
4
5
Accuracy Check
Calculate accuracy to check how
accurate your results are.
from sklearn.metrics import accuracy_score
accuracy_score(y_test,predictions)*100
www.edureka.co/pythonData Science Certification Training
SUV Data Analysis
What factors made people more
interested in buying SUV?
1 A car company has released a new SUV in the market. Using the previous data about the sales of their
SUV’s, they want to predict the category of people who might be interested in buying this.
2
www.edureka.co/pythonData Science Certification Training
SUV Predictions
www.edureka.co/pythonData Science Certification Training
Session in a Minute
What is regression? Logistic: What & Why?
Use - Cases
Linear VS Logistic
Demo2: SUV PredictionDemo1: Titanic Analysis
No Code required
to implement RPA
No Downtime.
24/7 up and running
Improved Accuracy
Reduced Costs
0 And 1
Yes And No
True And False
High And Low
Linear Regression Logistic Regression
Continuous variables1
Solves Regression Problems2
Straight line Curve3
Categorical variables1
Solves Classification Problems2
S-Curve3
Copyright © 2018, edureka and/or its affiliates. All rights reserved.
Don’t just learn it, MASTER it with
Logistic Regression in Python | Logistic Regression Example | Machine Learning Algorithms | Edureka

More Related Content

PPTX
Logistic Regression | Logistic Regression In Python | Machine Learning Algori...
PDF
Linear Regression vs Logistic Regression | Edureka
PDF
Campus Network Design version 8
PDF
Dimensionality Reduction
PPTX
Linear Regression Analysis | Linear Regression in Python | Machine Learning A...
ODP
Machine Learning with Decision trees
PDF
Linear regression
PPTX
Logistic regression
Logistic Regression | Logistic Regression In Python | Machine Learning Algori...
Linear Regression vs Logistic Regression | Edureka
Campus Network Design version 8
Dimensionality Reduction
Linear Regression Analysis | Linear Regression in Python | Machine Learning A...
Machine Learning with Decision trees
Linear regression
Logistic regression

What's hot (20)

ODP
Machine Learning With Logistic Regression
PDF
Logistic regression
PDF
Logistic regression in Machine Learning
PDF
Understanding Bagging and Boosting
PPTX
Logistic regression
PDF
Logistic regression
PPTX
Logistic Regression.pptx
PPTX
Presentation on unsupervised learning
PDF
Logistic Regression Analysis
PPTX
Ml3 logistic regression-and_classification_error_metrics
PPTX
Random forest algorithm
PPT
2.4 rule based classification
PDF
Decision trees in Machine Learning
PDF
Anomaly detection
PPTX
Logistic regression
PDF
Dimensionality Reduction
PPTX
Feature selection concepts and methods
PPTX
Support vector machine
PPTX
K Nearest Neighbor Algorithm
PPTX
Machine learning session4(linear regression)
Machine Learning With Logistic Regression
Logistic regression
Logistic regression in Machine Learning
Understanding Bagging and Boosting
Logistic regression
Logistic regression
Logistic Regression.pptx
Presentation on unsupervised learning
Logistic Regression Analysis
Ml3 logistic regression-and_classification_error_metrics
Random forest algorithm
2.4 rule based classification
Decision trees in Machine Learning
Anomaly detection
Logistic regression
Dimensionality Reduction
Feature selection concepts and methods
Support vector machine
K Nearest Neighbor Algorithm
Machine learning session4(linear regression)
Ad

Similar to Logistic Regression in Python | Logistic Regression Example | Machine Learning Algorithms | Edureka (20)

PDF
Logistic Regression in R | Machine Learning Algorithms | Data Science Trainin...
PPTX
ML Workshop at SACON 2018
PPTX
Python-Operators-and-Type-Conversion.pptx
PDF
Regression: A skin-deep dive
PPTX
制約解消によるプログラム検証・合成 (第1回ステアラボソフトウェア技術セミナー)
PDF
Hands-on Tutorial of Machine Learning in Python
PPTX
APSEC2020 Keynote
PDF
Machine learning pt.1: Artificial Neural Networks ® All Rights Reserved
PDF
IRJET- Solving Quadratic Equations using C++ Application Program
PPTX
ch12 (1).pptx Himalaya shampoo and conditioner for the baby is the message fo...
PPT
fdfgddgfgdfdfsfsfetstgfdrterteeseeretrtr
PDF
Type and proof structures for concurrency
PDF
ppt - Deep Learning From Scratch.pdf
PPTX
unit-5 Data Wrandling weightage marks.pptx
PPT
Digital Logic & Design (DLD) presentation
PDF
working with python
PDF
Machine Learning_Unit_II_Regression_notes.pdf
PPT
Beyond Classification and Ranking: Constrained Optimization of the ROI
PPTX
CST413 KTU S7 CSE Machine Learning Supervised Learning Classification Algorit...
PDF
Module 3 Course Slides Lesson 1 McGill University
Logistic Regression in R | Machine Learning Algorithms | Data Science Trainin...
ML Workshop at SACON 2018
Python-Operators-and-Type-Conversion.pptx
Regression: A skin-deep dive
制約解消によるプログラム検証・合成 (第1回ステアラボソフトウェア技術セミナー)
Hands-on Tutorial of Machine Learning in Python
APSEC2020 Keynote
Machine learning pt.1: Artificial Neural Networks ® All Rights Reserved
IRJET- Solving Quadratic Equations using C++ Application Program
ch12 (1).pptx Himalaya shampoo and conditioner for the baby is the message fo...
fdfgddgfgdfdfsfsfetstgfdrterteeseeretrtr
Type and proof structures for concurrency
ppt - Deep Learning From Scratch.pdf
unit-5 Data Wrandling weightage marks.pptx
Digital Logic & Design (DLD) presentation
working with python
Machine Learning_Unit_II_Regression_notes.pdf
Beyond Classification and Ranking: Constrained Optimization of the ROI
CST413 KTU S7 CSE Machine Learning Supervised Learning Classification Algorit...
Module 3 Course Slides Lesson 1 McGill University
Ad

More from Edureka! (20)

PDF
What to learn during the 21 days Lockdown | Edureka
PDF
Top 10 Dying Programming Languages in 2020 | Edureka
PDF
Top 5 Trending Business Intelligence Tools | Edureka
PDF
Tableau Tutorial for Data Science | Edureka
PDF
Python Programming Tutorial | Edureka
PDF
Top 5 PMP Certifications | Edureka
PDF
Top Maven Interview Questions in 2020 | Edureka
PDF
Linux Mint Tutorial | Edureka
PDF
How to Deploy Java Web App in AWS| Edureka
PDF
Importance of Digital Marketing | Edureka
PDF
RPA in 2020 | Edureka
PDF
Email Notifications in Jenkins | Edureka
PDF
EA Algorithm in Machine Learning | Edureka
PDF
Cognitive AI Tutorial | Edureka
PDF
AWS Cloud Practitioner Tutorial | Edureka
PDF
Blue Prism Top Interview Questions | Edureka
PDF
Big Data on AWS Tutorial | Edureka
PDF
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
PDF
Kubernetes Installation on Ubuntu | Edureka
PDF
Introduction to DevOps | Edureka
What to learn during the 21 days Lockdown | Edureka
Top 10 Dying Programming Languages in 2020 | Edureka
Top 5 Trending Business Intelligence Tools | Edureka
Tableau Tutorial for Data Science | Edureka
Python Programming Tutorial | Edureka
Top 5 PMP Certifications | Edureka
Top Maven Interview Questions in 2020 | Edureka
Linux Mint Tutorial | Edureka
How to Deploy Java Web App in AWS| Edureka
Importance of Digital Marketing | Edureka
RPA in 2020 | Edureka
Email Notifications in Jenkins | Edureka
EA Algorithm in Machine Learning | Edureka
Cognitive AI Tutorial | Edureka
AWS Cloud Practitioner Tutorial | Edureka
Blue Prism Top Interview Questions | Edureka
Big Data on AWS Tutorial | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Kubernetes Installation on Ubuntu | Edureka
Introduction to DevOps | Edureka

Recently uploaded (20)

PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Chapter 3 Spatial Domain Image Processing.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
cuic standard and advanced reporting.pdf
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Electronic commerce courselecture one. Pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Encapsulation_ Review paper, used for researhc scholars
Reach Out and Touch Someone: Haptics and Empathic Computing
20250228 LYD VKU AI Blended-Learning.pptx
Advanced methodologies resolving dimensionality complications for autism neur...
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Chapter 3 Spatial Domain Image Processing.pdf
The AUB Centre for AI in Media Proposal.docx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
cuic standard and advanced reporting.pdf
NewMind AI Weekly Chronicles - August'25 Week I
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Machine learning based COVID-19 study performance prediction
Electronic commerce courselecture one. Pdf
Understanding_Digital_Forensics_Presentation.pptx
MYSQL Presentation for SQL database connectivity
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Unlocking AI with Model Context Protocol (MCP)
Bridging biosciences and deep learning for revolutionary discoveries: a compr...

Logistic Regression in Python | Logistic Regression Example | Machine Learning Algorithms | Edureka

  • 2. www.edureka.co/pythonData Science Certification Training Topics Covered in Today’s Training What is Regression? Logistic regression: What and Why? Linear Vs Logistic Regression Use- Cases Demo
  • 3. Copyright © 2018, edureka and/or its affiliates. All rights reserved. What Is Regression
  • 4. www.edureka.co/pythonData Science Certification Training What is Regression? Regression Analysis is a predictive modelling technique It estimates the relationship between a dependent (target) and an independent variable(predictor)
  • 5. Copyright © 2018, edureka and/or its affiliates. All rights reserved. Logistic Regression: What And Why
  • 6. www.edureka.co/pythonData Science Certification Training Logistic Regression: What And Why? Logistic Regression produces results in a binary format which is used to predict the outcome of a categorical dependent variable. So the outcome should be discrete/ categorical such as: No Code required to implement RPA No Downtime. 24/7 up and running Improved Accuracy Reduced Costs 0 OR 1 Yes OR No True OR False High And Low
  • 7. www.edureka.co/pythonData Science Certification Training Why Not Linear Regression? Y-axis X-axis 0 1 Since our value of Y will be between 0 and 1, the linear line has to be clipped at 0 and 1.
  • 8. www.edureka.co/pythonData Science Certification Training Why Not Linear Regression? Y-axis X-axis 0 1 With this, our resulting curve cannot be formulated into a single formula. Hence we came up with Logistic!
  • 9. www.edureka.co/pythonData Science Certification Training Logistic Regression Curve The Sigmoid “S” Curve
  • 10. www.edureka.co/pythonData Science Certification Training The Sigmoid “S” Curve With this, the threshold value indicates the probability of winning or losing 0.5 THRESHOLD VALUE Logistic Regression Curve
  • 11. www.edureka.co/pythonData Science Certification Training The Logistic Regression Equation is derived from the Straight Line Equation Logistic Regression Equation Equation of a straight line Y = C + BIX1 + B2X2 +…. Range is from –(infinity) to (infinity)
  • 12. www.edureka.co/pythonData Science Certification Training The Logistic Regression Equation is derived from the Straight Line Equation Logistic Regression Equation Equation of a straight line Y = C + BIX1 + B2X2 +…. Range is from –(infinity) to (infinity) Let’s try to reduce the Logistic Regression Equation from Straight Line Equation Y = C + BIX1 + B2X2 +…. In Logistic equation Y can be only from 0 to 1
  • 13. www.edureka.co/pythonData Science Certification Training Logistic Regression Equation Equation of a straight line Range is from –(infinity) to (infinity) Let’s try to reduce the Logistic Regression Equation from Straight Line Equation In Logistic equation Y can be only from 0 to 1 Now , to get the range of Y between 0 and infinity, let’s transform Y Now, the range is between 0 to infinity The Logistic Regression Equation is derived from the Straight Line Equation Y = C + BIX1 + B2X2 +…. Y = C + BIX1 + B2X2 +…. Y= 0 then 0 Y= 1 then infinity Y 1-Y
  • 14. www.edureka.co/pythonData Science Certification Training Logistic Regression Equation Equation of a straight line Range is from –(infinity) to (infinity) Let’s try to reduce the Logistic Regression Equation from Straight Line Equation In Logistic equation Y can be only from 0 to 1 Now , to get the range of Y between 0 and infinity, let’s transform Y Now, the range is between 0 to infinity Let us transform it further, to get range between –(infinity) and (infinity) log Y 1-Y Y = C + BIX1 + B2X2 +…. Final Logistic Regression Equation The Logistic Regression Equation is derived from the Straight Line Equation Y = C + BIX1 + B2X2 +…. Y = C + BIX1 + B2X2 +…. Y= 0 then 0 Y= 1 then infinity Y 1-Y
  • 15. Copyright © 2018, edureka and/or its affiliates. All rights reserved. Linear Logistic
  • 16. www.edureka.co/pythonData Science Certification Training Linear Vs Logistic Regression Linear Regression Logistic Regression Continuous variables1 Solves Regression Problems2 Straight line3 Categorical variables1 Solves Classification Problems2 S-Curve3
  • 17. Copyright © 2018, edureka and/or its affiliates. All rights reserved. Logistic Regression: Use - Cases
  • 18. www.edureka.co/pythonData Science Certification Training Logistic Regression: Use - Cases Weather Predictions
  • 19. www.edureka.co/pythonData Science Certification Training Logistic Regression: Use - Cases Classification Problems
  • 20. www.edureka.co/pythonData Science Certification Training Logistic Regression: Use - Cases Determines Illness
  • 21. Copyright © 2018, edureka and/or its affiliates. All rights reserved. Demo
  • 22. www.edureka.co/pythonData Science Certification Training 1 Titanic Data Analysis Explore titanic dataset and explore about the people, both those who survived and those who did not. With today's technology, answering questions through data analysis is now easier than ever. 1 What factors made people more likely to survive the sinking of the Titanic?
  • 24. www.edureka.co/pythonData Science Certification Training Implement Logistic Regression Analyzing Data 1 2 3 4 5 Collecting Data Train & Test Data Wrangling Accuracy Check
  • 25. www.edureka.co/pythonData Science Certification Training Implement Logistic Regression 1 2 3 4 5 Collect Data: Import Libraries
  • 26. www.edureka.co/pythonData Science Certification Training Implement Logistic Regression 1 2 3 4 5 Analyzing Data Creating different plot to check relationship between variables
  • 27. www.edureka.co/pythonData Science Certification Training Implement Logistic Regression 1 2 3 4 5 Analyzing Data Creating different plot to check relationship between variables
  • 28. www.edureka.co/pythonData Science Certification Training Implement Logistic Regression 1 2 3 4 5 Data Wrangling Clean the data by removing the Nan values and unnecessary columns in the dataset
  • 29. www.edureka.co/pythonData Science Certification Training Implement Logistic Regression 1 2 3 4 5 Train & Test Data Build the model on the train data and predict the output on the test data logistic = LogisticRegression() logistic.fit(train_X,train_Y)
  • 30. www.edureka.co/pythonData Science Certification Training Implement Logistic Regression 1 2 3 4 5 Accuracy Check Calculate accuracy to check how accurate your results are. from sklearn.metrics import accuracy_score accuracy_score(y_test,predictions)*100
  • 31. www.edureka.co/pythonData Science Certification Training SUV Data Analysis What factors made people more interested in buying SUV? 1 A car company has released a new SUV in the market. Using the previous data about the sales of their SUV’s, they want to predict the category of people who might be interested in buying this. 2
  • 33. www.edureka.co/pythonData Science Certification Training Session in a Minute What is regression? Logistic: What & Why? Use - Cases Linear VS Logistic Demo2: SUV PredictionDemo1: Titanic Analysis No Code required to implement RPA No Downtime. 24/7 up and running Improved Accuracy Reduced Costs 0 And 1 Yes And No True And False High And Low Linear Regression Logistic Regression Continuous variables1 Solves Regression Problems2 Straight line Curve3 Categorical variables1 Solves Classification Problems2 S-Curve3
  • 34. Copyright © 2018, edureka and/or its affiliates. All rights reserved. Don’t just learn it, MASTER it with