Interactive Neural Network Learning Lab

Explore how neural networks make predictions through a real-world HR analytics example

🎓 Learning Objectives

  • Understand neural network architecture and data flow
  • Explore how input normalization affects predictions
  • Visualize weight connections and their impact
  • Learn about activation functions and probability outputs

Likely to Stay

Probability of staying: 56.8%

Input Parameters

Years (use decimals for months, e.g., 1.5 = 1 year 6 months)
25y
$90k

Neural Network Architecture

Input LayerHidden LayerOutput Layer0.40Tenure: 2.0y0.33Age: 25y0.67Salary: $90k0.270.660.320.640.43

Input Normalization

Formula: normalized = (value - min) / (max - min)
tenure = (0.40 - 0) / (20 - 0)
age = (0.33 - 18) / (65 - 18)
salary = (0.67 - 30) / (200 - 30)

Activation Function (σ)

σ(x) = 1 / (1 + e⁻ˣ)
Properties:
  • Maps any real number to (0,1)
  • Steepest at x=0: σ'(0) = 0.25
  • Symmetric: σ(-x) = 1 - σ(x)

Forward Propagation

General Formula:
1. Hidden Layer: hᵢ = σ(Σ wᵢⱼxⱼ + bᵢ)
2. Output Layer: y = σ(Σ wᵢhᵢ + b)
Hidden Layer Values:
x1 = (-0.80 × 0.40) + (-0.60 × 0.33) + (-0.70 × 0.67) + 0.1 = -0.887
Weighted inputs: [-0.320, -0.200, -0.467]
h1 = σ(x1) = σ(-0.887) = 0.292
x2 = (0.60 × 0.40) + (0.50 × 0.33) + (0.40 × 0.67) + 0.1 = 0.773
Weighted inputs: [0.240, 0.167, 0.267]
h2 = σ(x2) = σ(0.773) = 0.684
x3 = (-0.50 × 0.40) + (-0.40 × 0.33) + (-0.60 × 0.67) + 0.1 = -0.633
Weighted inputs: [-0.200, -0.133, -0.400]
h3 = σ(x3) = σ(-0.633) = 0.347
x4 = (0.40 × 0.40) + (0.30 × 0.33) + (0.50 × 0.67) + 0.1 = 0.693
Weighted inputs: [0.160, 0.100, 0.333]
h4 = σ(x4) = σ(0.693) = 0.667
Output Layer Value:
Hidden layer outputs: [0.292, 0.684, 0.347, 0.667]
x = (0.80×0.292) + (-0.60×0.684) + (0.70×0.347) + (-0.50×0.667) + 0.1 = -0.168
Weighted hidden: [0.233, -0.411, 0.243, -0.333]
y = σ(x) = σ(-0.168) = 0.458

Loss Function (Binary Cross-Entropy)

BCE = -[y·log(ŷ) + (1-y)·log(1-ŷ)]
where y is true label (0 or 1) and ŷ is predicted probability
Properties:
  • Measures prediction error for binary classification
  • Range: [0, ∞) where 0 means perfect prediction
  • Penalizes confident wrong predictions heavily
  • Derivative: ∂BCE/∂ŷ = -y/ŷ + (1-y)/(1-ŷ)
Example loss calculation (if actual = 1):
ŷ = 0.458
BCE = -[1·log(0.458) + (1-1)·log(1-0.458)]
= -[1·(-0.781) + 0·(-0.613)]
= 0.781

Analysis

Stay Scenario

Based on the current inputs, the model predicts a 56.8% probability of employee retention.

Key Factors:

  • Optimal tenure range indicates stability
  • Age indicates career-focused phase
  • Competitive salary promotes retention

Scenario Analysis

Current values compared to retention indicators:

Input Analysis:

  • Tenure: 2 years (ideal: 2-5)
  • Age: 25 years (ideal: 25-35)
  • Salary: $90k (ideal: 90k-120k)

Values within ideal ranges strengthen retention probability

Historical Data Comparison

Tenure Distribution (years)Current: 2
05+ years
Age DistributionCurrent: 25
2035+ years
Salary Distribution ($k)Current: $90k
$30k$135k+

Stay Statistics

  • Avg Tenure: 3.9 years
  • Avg Age: 31.2 years
  • Avg Salary: $114k

Leave Statistics

  • Avg Tenure: 0.75 years
  • Avg Age: 24.2 years
  • Avg Salary: $52.1k

Historical Data

TenureAgeSalaryAttrition
0.52245Y
0.82448Y
12355Y
0.32140Y
1.22575Y
0.42342Y
0.72650Y
1.12458Y
0.62546Y
0.92762Y
4.533130N
3.229110N
432125N
3.831115N
2.52795N
2.82898N
535135N
1.52665Y
3.530105N
0.92552Y