ABCDEFGHIJKLMNOPQRSTUVWXYZ
1
[Description] Logistic Regression - Binary Classification, MLE, Confusion Matrix, ROC & AUC
2
3
Logistic Regression Worksheet
4
5
Learning Objectives:
6
7
1. Understand logistic regression for binary classification
8
2. Calculate odds and log-odds (logit)
9
3. Apply the sigmoid function to convert log-odds to probability
10
4. Compute predicted probabilities given β₀ and β₁
11
5. Understand the concept of maximum likelihood estimation
12
6. Build and interpret a confusion matrix for classification
13
7. Calculate classification metrics: Accuracy, Sensitivity, Specificity, Precision
14
8. Understand the ROC curve and calculate AUC using the trapezoidal rule
15
Key Formulas:
16
Linear predictor:z = β₀ + β₁X
17
Sigmoid function:p = σ(z) = 1/(1+e⁻ᶻ)
18
Logistic model:P(Y=1|X) = 1/(1+e⁻⁽β₀⁺β₁ˣ⁾)
19
Odds:odds = p/(1-p) = e⁽β₀⁺β₁ˣ⁾
20
Log-odds (logit):logit(p) = ln(p/(1-p)) = β₀ + β₁X
21
Interpretation:e^β₁ = odds ratio for 1-unit increase in X
22
23
Classification:Ŷ = 1 if p̂ ≥ threshold, else Ŷ = 0
24
TPR (Sensitivity):TP / (TP + FN)
25
FPR:FP / (FP + TN)
26
AUC (Trapezoid):
Σ (FPR_{i+1} - FPR_i) × (TPR_{i+1} + TPR_i) / 2
27
28
Color Guide:
29
30
Given Data (Input)
31
Intermediate Calculations
32
Final Results
33
Correct Answer (✓)
34
Incorrect Answer (✗)
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100