| A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | [Description] This worksheet demonstrates binary classification using logistic regression with sigmoid activation. | |||||||||||||||||||||||||
2 | Logistic Regression Binary Classification Practice Worksheet | |||||||||||||||||||||||||
3 | ||||||||||||||||||||||||||
4 | ||||||||||||||||||||||||||
5 | ||||||||||||||||||||||||||
6 | [Learning Objectives] | |||||||||||||||||||||||||
7 | 1. Understand binary classification problem using Logistic Regression | |||||||||||||||||||||||||
8 | 2. Role and calculation of Sigmoid activation function | |||||||||||||||||||||||||
9 | 3. Understand Binary Cross-Entropy (BCE) loss function | |||||||||||||||||||||||||
10 | 4. Derive simplified gradient of BCE + Sigmoid | |||||||||||||||||||||||||
11 | 5. Update weights through backpropagation | |||||||||||||||||||||||||
12 | ||||||||||||||||||||||||||
13 | [Network Structure] | |||||||||||||||||||||||||
14 | • Input matrix X: 10 samples × 8 features (10×8 matrix) | |||||||||||||||||||||||||
15 | • Weight matrix W: 8 features × 1 output (8×1 vector) | |||||||||||||||||||||||||
16 | • Bias b: Scalar | |||||||||||||||||||||||||
17 | • Linear combination Z: Z = X · W + b | |||||||||||||||||||||||||
18 | • Activation function: Sigmoid → Y_pred = σ(Z) = 1/(1+e^(-Z)) | |||||||||||||||||||||||||
19 | • Output Y_pred: 10 × 1 (probability values between 0~1) | |||||||||||||||||||||||||
20 | • Ground truth Y_true: 10 × 1 (0 or 1 - binary label) | |||||||||||||||||||||||||
21 | • Loss function: Binary Cross-Entropy (BCE) | |||||||||||||||||||||||||
22 | ||||||||||||||||||||||||||
23 | [Mathematical Expression] | |||||||||||||||||||||||||
24 | Forward: | |||||||||||||||||||||||||
25 | Z = X · W + b (Linear combination) | |||||||||||||||||||||||||
26 | Y_pred = σ(Z) = 1 / (1 + e^(-Z)) (Sigmoid activation) | |||||||||||||||||||||||||
27 | ||||||||||||||||||||||||||
28 | Loss (BCE): | |||||||||||||||||||||||||
29 | L = -(1/n) × Σ[y_true × log(y_pred) + (1-y_true) × log(1-y_pred)] | |||||||||||||||||||||||||
30 | ||||||||||||||||||||||||||
31 | Gradient (BCE + Sigmoid simplified): | |||||||||||||||||||||||||
32 | ∂L/∂Z = (1/n) × (Y_pred - Y_true) ★ Key formula! | |||||||||||||||||||||||||
33 | ∂L/∂W = X^T · ∂L/∂Z | |||||||||||||||||||||||||
34 | ∂L/∂b = Σ(∂L/∂Z) | |||||||||||||||||||||||||
35 | ||||||||||||||||||||||||||
36 | Update: | |||||||||||||||||||||||||
37 | W_new = W - lr × ∂L/∂W | |||||||||||||||||||||||||
38 | b_new = b - lr × ∂L/∂b | |||||||||||||||||||||||||
39 | ||||||||||||||||||||||||||
40 | [Sigmoid Function] | |||||||||||||||||||||||||
41 | • Output range: 0 < σ(z) < 1 (interpretable as probability) | |||||||||||||||||||||||||
42 | • When z = 0: σ(0) = 0.5 | |||||||||||||||||||||||||
43 | • When z > 0: σ(z) > 0.5 (classified as positive class) | |||||||||||||||||||||||||
44 | • When z < 0: σ(z) < 0.5 (classified as negative class) | |||||||||||||||||||||||||
45 | • Derivative: σ'(z) = σ(z) × (1 - σ(z)) | |||||||||||||||||||||||||
46 | ||||||||||||||||||||||||||
47 | [Color Legend] | |||||||||||||||||||||||||
48 | ■ Input matrix (X) | |||||||||||||||||||||||||
49 | ■ Weight (W) | |||||||||||||||||||||||||
50 | ■ Linear combination (Z) | |||||||||||||||||||||||||
51 | ■ Sigmoid output (Y_pred) | |||||||||||||||||||||||||
52 | ■ Output/Result | |||||||||||||||||||||||||
53 | ■ Gradient | |||||||||||||||||||||||||
54 | ■ Student input cell | |||||||||||||||||||||||||
55 | ■ Answer | |||||||||||||||||||||||||
56 | ■ Wrong | |||||||||||||||||||||||||
57 | ||||||||||||||||||||||||||
58 | [How to Use] | |||||||||||||||||||||||||
59 | 1. Enter calculation results in yellow cells in Forward_Propagation sheet | |||||||||||||||||||||||||
60 | 2. Check ✓(correct) or ✗(wrong) in verification cells | |||||||||||||||||||||||||
61 | 3. Tolerance: 0.0001 (up to 4 decimal places) | |||||||||||||||||||||||||
62 | 4. Hint: When calculating Sigmoid, first compute e^(-z), then 1/(1+e^(-z)) | |||||||||||||||||||||||||
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 | ||||||||||||||||||||||||||