๐ณ ANN Credit Card Approval — Weight & Bias Update
Step-by-step example showing how an Artificial Neural Network uses Age, Salary and Credit Score to predict credit-card approval and then updates its weights and biases using loss.
1. Problem Statement
Suppose an ANN has to predict whether a person should be approved for a credit card.
Target: y = 1 → Approved y = 0 → Not Approved
2. Input Data
Consider one applicant:
| Feature | Symbol | Value |
|---|---|---|
| Age | x₁ | 30 |
| Salary | x₂ | 50,000 |
| Credit Score | x₃ | 700 |
Because salary and credit score have much larger numerical scales than age, we first normalize the inputs for this classroom example.
3. Normalize the Inputs
We will use simple normalized values:
Salary: x₂ = 50,000 / 100,000 = 0.50
Credit Score: x₃ = 700 / 850 ≈ 0.824
Therefore the ANN receives:
4. ANN Architecture
5. Initial Weights and Biases
Assume the ANN initially has:
| Parameter | Initial Value |
|---|---|
| Age Weight w₁ | 0.20 |
| Salary Weight w₂ | 0.40 |
| Credit Score Weight w₃ | 0.50 |
| Hidden Bias bโ | -0.30 |
| Hidden → Output Weight w₄ | 0.60 |
| Output Bias bโ | -0.20 |
| Learning Rate ฮท | 0.10 |
1 Forward Propagation — Hidden Neuron
The hidden neuron first calculates the weighted sum.
Substitute the values:
zโ = 0.060 + 0.200 + 0.412 - 0.300
zโ = 0.372
6. Hidden Neuron Activation
Apply the sigmoid activation function:
h = 1 / (1 + e⁻⁰·³⁷²)
h ≈ 0.592
2 Hidden → Output
Substitute:
zโ = 0.3552 - 0.20
zโ = 0.1552
Now apply sigmoid:
ลท ≈ 0.539
7. Actual Answer
Suppose the training dataset says that this applicant was approved.
ANN Prediction: ลท = 0.539
The ANN is predicting only about 53.9%, while the target is 1. Therefore the network needs to learn.
3 Calculate Loss
For this educational example, use Mean Squared Error for one example:
Substitute:
= ½(0.461)²
= ½(0.2125)
L ≈ 0.1063
4 Backpropagation — Output Error
First calculate:
= 0.539 - 1
= -0.461
For sigmoid:
Therefore:
= 0.539 × 0.461
≈ 0.2485
Output error signal:
= (-0.461)(0.2485)
ฮดโ ≈ -0.1146
5 Update Hidden → Output Weight
The gradient is:
≈ -0.06784
Now apply gradient descent:
= 0.60 - (0.10 × -0.06784)
= 0.60 + 0.006784
w₄(new) ≈ 0.60678
6 Update Output Bias
= -0.1146
Therefore:
= -0.20 - (0.10 × -0.1146)
= -0.20 + 0.01146
bโ(new) = -0.18854
7 Send the Error Back to Hidden Layer
The hidden neuron also contributed to the error.
First calculate hidden sigmoid derivative:
= 0.592(1 - 0.592)
= 0.592 × 0.408
≈ 0.2415
Therefore:
ฮดโ ≈ -0.01660
8 Update Age Weight
= (-0.01660)(0.30)
≈ -0.00498
= 0.20 + 0.000498
w₁(new) ≈ 0.20050
9 Update Salary Weight
= (-0.01660)(0.50)
≈ -0.00830
= 0.40 + 0.000830
w₂(new) ≈ 0.40083
10 Update Credit Score Weight
= (-0.01660)(0.824)
≈ -0.01368
= 0.50 + 0.001368
w₃(new) ≈ 0.50137
11 Update Hidden Bias
= -0.01660
= -0.30 - (0.10 × -0.01660)
= -0.30 + 0.001660
bโ(new) ≈ -0.29834
12. Weight & Bias Before and After Learning
| Parameter | Before | Gradient | After |
|---|---|---|---|
| Age Weight w₁ | 0.20000 | -0.00498 | 0.20050 |
| Salary Weight w₂ | 0.40000 | -0.00830 | 0.40083 |
| Credit Score Weight w₃ | 0.50000 | -0.01368 | 0.50137 |
| Hidden Bias bโ | -0.30000 | -0.01660 | -0.29834 |
| Output Weight w₄ | 0.60000 | -0.06784 | 0.60678 |
| Output Bias bโ | -0.20000 | -0.11460 | -0.18854 |
12 Run the ANN Again
Now use the updated weights and biases.
w₂ = 0.40083
w₃ = 0.50137
bโ = -0.29834
w₄ = 0.60678
bโ = -0.18854
New Hidden Weighted Sum:
≈ 0.3737
New Hidden Activation:
≈ 0.5924
New Output:
≈ 0.1709
ลท(new) = Sigmoid(0.1709)
≈ 0.5426
New Prediction ≈ 0.543
The prediction moved closer to the target 1.
13. New Loss
= ½(0.4574)²
≈ 0.1046
New Loss ≈ 0.1046
✅ LOSS DECREASED
14. What Actually Happened?
The network has completed one learning step.
During actual training, this process is repeated for many training examples and many epochs.
15. General Weight Update Formula
w(new) = w(old) - ฮท × ∂L/∂w
Bias Update:
b(new) = b(old) - ฮท × ∂L/∂b
Where:
b = Bias
ฮท = Learning Rate
L = Loss
∂L/∂w = Weight Gradient
∂L/∂b = Bias Gradient
16. Why Is the Credit Score Weight Updated?
The gradient tells the ANN how strongly a particular input affects the loss.
Gradient: ∂L/∂w₃ ≈ -0.01368
Therefore: w₃(new) ≈ 0.50137
The weight does not mean that credit score alone determines approval. It is simply a learned parameter within this toy neural network.
17. Interactive Step-by-Step Learning
① Input
Salary = 0.50
Credit Score = 0.824
② Forward Pass
zโ = 0.372
h ≈ 0.592
③ Prediction
④ Loss
L ≈ 0.1063
⑤ Backpropagation
⑥ Update Weights
⑦ Update Biases
⑧ New Loss
New Loss ≈ 0.1046
18. Complete Learning Formula
z = x₁w₁ + x₂w₂ + x₃w₃ + b ↓ Sigmoid ↓ Prediction ↓ Compare with Actual Target ↓ Loss ↓ Backpropagation ↓ Gradient ↓ Weight Update
w(new) = w(old) - ฮท × gradient ↓ Bias Update
b(new) = b(old) - ฮท × gradient ↓ New Prediction ↓ New Loss ↓ Repeat
No comments:
Post a Comment