MLS - Logistic Regression
MLS - Logistic Regression
com
DLOE0CFJ6M
Logistic Regression
Positive (1) TP FP
• Accuracy = TP + TN / (TP + FP + FN + TN)
• Precision = TP / (TP + FP)
• Recall or sensitivity = TP / (TP+FN)
Negative (0) TN • Specificity = TN / (TN + FP)
FN
# Total
Model Misses out
Patients – 100
Cancer rate – predicts that Accuracy – critical
# of Patients
2% no one has 98% patients
having cancer-
cancer having cancer
2
● F1 Score is a measure that takes into account both Precision and Recall.
● F1 Score is the harmonic mean of Precision and Recall. Therefore, this score takes both False Positives and False
Negatives into account.
[email protected]
DLOE0CFJ6M
● The highest possible value of an F1 Score is 1, indicating perfect precision and recall, and the lowest possible value is
0.
Sigmoid function:
● The inverse of the logit function is the sigmoid function.
● The Sigmoid Function can take any real value and map it to a value between 0 and 1.
● It is also called Logistic Function and gives an S shaped curve.
Sigmoid(x) = 1 / (1 + e^(-x))
This file is meant for personal use by [email protected] only.
Sharing or publishing the contents in part or full is liable for legal action.
Proprietary content. © Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited. 10
What is the relationship between Logit, Sigmoid and Logistic
Regression
● Linear Regression Equation
○ Y = a1 + a2*x + error
● If the dependent variable Y is the logit function
○ Logit(P) = Y = a1 + a2*x + error
where P = the probability of sample belonging to a class
[email protected]
DLOE0CFJ6M○ log(P/1-P) = a1 + a2*x + error
● Apply the sigmoid function over LHS and RHS to get probabilities,
○ sigmoid(log(P/1-P)) = sigmoid( a1 + a2*x + error )
● So, we get,
○ P = 1 / (1 + e^-(a1 + a2*x + error))
○ This ‘P’ is the output of the Logistic Regression model, i.e. we are getting the probability of sample
belonging to a class.
● Usually if P>0.5, we mark it as positive, and if P<0.5, we mark it as negative
● This cut-off point, known as Threshold, can be changed between 0 to 1, depending on the context of the problem.
This file is meant for personal use by [email protected] only.
Sharing or publishing the contents in part or full is liable for legal action.
Proprietary content. © Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited. 11
ROC Curve