0% found this document useful (0 votes)
9 views28 pages

4.logistic Regression

Uploaded by

aqsa.afzal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views28 pages

4.logistic Regression

Uploaded by

aqsa.afzal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

Logistic Regression

Logistic Regression
• Logistic regression is a supervised machine learning algorithm used
for classification tasks where the goal is to predict the probability that
an instance belongs to a given class or not.
• Logistic regression is a statistical algorithm which analyze the
relationship between two data factors
• Logistic regression is used for binary classification where we use
sigmoid function, that takes input as independent variables and
produces a probability value between 0 and 1.

• For example, we have two classes Class 0 and Class 1 if the value of
the logistic function for an input is greater than 0.5 (threshold value)
then it belongs to Class 1 it belongs to Class 0. It’s referred to as
regression because it is the extension of linear regression but is
mainly used for classification problems.
How does Logistic Regression work?
Logistic Regression Equation
You must be wondering how logistic
regression squeezes the output of linear
regression between 0 and 1.
• Maximum Likelihood
• Odds of Success
• Logit function
Odds of success
We all know the equation of the best fit line in
linear regression is:

instead of y we are taking probabilities (P) and we take “odds”


of P
• To take the log of odds which has a range from (-∞,+∞).

Rest of the math is here:


Sigmoid Function
Logistic Regresssion- Classification
Studied Slept Passed

4.85 9.63 1

8.62 3.23 0

5.43 8.23 1

9.21 6.34 0
Cost Function
• If we try to use the cost function
of the linear regression in
‘Logistic Regression’ then it
would be of no use as it would
end up being a non-convex
function with many local
minimums, in which it would be
very difficult to minimize the
cost value and find the global
minimum.
binary cross-entropy/log loss
Gradient Descent Optimization
• Gradient descent changes the
value of our weights in such a
way that it always converges to
minimum point or we can also
say that, it aims at finding the
optimal weights which minimize
the loss function of our model. It
is an iterative method that finds
the minimum of a function by
figuring out the slope at a
random point and then moving
in the opposite direction.
Alpha- The Learning Rate
Update coefficents and intercept
References
• https://medium.com/intro-to-artificial-intelligence/logistic-regression
-using-gradient-descent-bf8cbe749ceb
• https://ml-cheatsheet.readthedocs.io/en/latest/logistic_regression.h
tml
• https://www.analyticsvidhya.com/blog/2021/08/conceptual-underst
anding-of-logistic-regression-for-data-science-beginners/
• https://machinelearningmastery.com/logistic-regression-for-machine
-learning/
• https://www.analyticsvidhya.com/blog/2020/11/binary-cross-entrop
y-aka-log-loss-the-cost-function-used-in-logistic-regression/

You might also like