5. Classification with Deep Learning (CNNs)

Convolution, pooling, batch normalization, dropout, regularization, optimizers, evaluation metrics

Contents
1. Limitations of Fully Connected Networks 2. CNN Innovations: Local Connectivity & Weight Sharing 3. The Convolution Operation 4. 3D Convolutions and Feature Maps 5. Pooling Layers 6. Full CNN Pipeline 7. 1×1 Convolution 8. Stride, Padding, and Output Size 9. Overfitting and Regularization 10. Dropout 11. Batch Normalization 12. Weight Initialization & Transfer Learning 13. Gradient Descent Variants & Optimizers 14. What Does a CNN See? 15. Classification Metrics Interactive: Weight Sharing Explainer Interactive: Pooling Operations Interactive: CNN Forward Pass Interactive: CNN Layer Builder Interactive: Output Size Calculator Flashcards

1. Limitations of Fully Connected Networks for Images

Before CNNs, neural networks used fully connected layers where every input pixel connects to every neuron. This creates serious problems for image data:

Fully connected network with all-to-all connections
Fully connected network: every input neuron connects to every hidden neuron. For even modest images, this creates an impractical number of parameters.
ProblemExplanation
Spatial structure ignoredFCNs flatten images to 1D, destroying 2D spatial relationships (edges, local patterns) crucial for vision.
Enormous parameter countA 256×256 RGB image with a single 1000-neuron FC layer requires ~197 million weights. Impractical.
No translation invarianceA shifted object activates entirely different neurons; the network must re-learn every pattern at every location.
Poor generalizationAll-to-all connections overfit easily and generalize poorly to unseen images.
Key question
Can we build a better architecture specifically for images? Yes — Convolutional Neural Networks (CNNs), introduced conceptually by Yann LeCun in LeNet-5 (1989), but only made practical by GPU acceleration around 2011.

2. CNN Innovations: Local Connectivity and Weight Sharing

Innovation 1: Local Connectivity

Instead of connecting each neuron to all inputs, each CNN neuron connects only to a small local region called its receptive field (e.g., 3×3 pixels). This mirrors how the visual cortex works: neurons respond to local regions of the visual field.

Fully connected vs convolutional layer comparison
Left: FC layer connects to all inputs. Right: Conv layer connects each neuron to only its local receptive field.

Innovation 2: Weight Sharing

The same filter weights are applied at every spatial position. A 3×3 filter has only 9 learnable weights regardless of image size. This is the core insight that makes CNNs parameter-efficient.

Convolutional Layer: Weight Sharing
$$\text{output}(i, j) = \sum_{m} \sum_{n} \text{input}(i+m,\; j+n) \cdot w(m, n) + b$$ The same $w(m,n)$ are used at every position $(i,j)$. A 3×3 filter: 9 weights + 1 bias = 10 parameters, regardless of image size.
Neuron weights forming a convolutional filter
The network weights literally become the convolutional filter parameters. Training learns the optimal filter values.

Parameter Count Comparison

Layer TypeExample ConfigurationParameters
Fully connected32×32×3 input, 16 neurons$32 \times 32 \times 3 \times 16 = 49{,}152$
Convolutional16 filters of 3×3×3$16 \times (3 \times 3 \times 3 + 1) = 448$
Key insight
CNNs use the same fundamental principles as standard neural networks (neurons, weights, biases, backpropagation), but replace all-to-all connectivity with local, shared-weight connections. This gives translation equivariance: the same pattern is detected regardless of its position in the image.
Weight Sharing Explainer
Position 0 of 16

3. The Convolution Operation

2D Discrete Convolution

2D Convolution Formula
$$\text{Output}(i, j) = \sum_{m=0}^{k_h - 1} \sum_{n=0}^{k_w - 1} \text{Input}(i + m, \; j + n) \cdot \text{Kernel}(m, n) + b$$ where $k_h \times k_w$ is the kernel size. This is technically cross-correlation, but called convolution by convention in deep learning.
3D convolution filter sliding over input to produce activation map
A filter slides across the input, computing a dot product at each position to produce an activation (feature) map.

Worked Example (5×5 image, 3×3 kernel)

Convolution computation: position (0,0)

Image (top-left 3×3 subregion): $\begin{bmatrix}1 & 1 & 1 \\ 0 & 1 & 1 \\ 0 & 0 & 1\end{bmatrix}$, Kernel: $\begin{bmatrix}1 & 0 & 1 \\ 0 & 1 & 0 \\ 1 & 0 & 1\end{bmatrix}$

Element-wise multiply and sum:
$1\cdot1 + 1\cdot0 + 1\cdot1 + 0\cdot0 + 1\cdot1 + 1\cdot0 + 0\cdot1 + 0\cdot0 + 1\cdot1 = 4$

Output dimensions for a 5×5 input with 3×3 kernel (stride 1, no padding): $(5-3+1)\times(5-3+1) = 3\times3$.

Convolution worked example
Worked convolution: 5x5 image, 3x3 kernel, stride 1, producing a 3x3 output.

After Convolution: Activation Function

The convolution output is passed through a non-linear activation function (typically ReLU):

$$\text{FeatureMap}(i,j) = \text{ReLU}\!\Big(\sum_{m}\sum_{n} \text{Input}(i+m, j+n) \cdot w(m,n) + b\Big)$$

This is directly analogous to classical image filtering (Sobel, Gaussian), except the filter weights are learned from data rather than hand-designed.

Sobel filter examples
Classical Sobel filters detect horizontal and vertical gradients. CNN filters learn to detect the features most useful for the task.

4. 3D Convolutions and Feature Maps

Why 3D?

Real images have multiple channels (RGB = 3 channels). Each CNN layer also produces multiple output channels (feature maps). Convolution is therefore inherently 3D.

3D Convolution
A single filter has shape $k_h \times k_w \times d_{\text{in}}$ (depth must equal number of input channels): $$\text{output}(i,j) = \sum_{c=1}^{d_{\text{in}}} \sum_{m=0}^{k_h-1} \sum_{n=0}^{k_w-1} \text{input}(i+m,\; j+n,\; c) \cdot w(m, n, c) + b$$ One filter produces one 2D feature map. $N$ filters produce an output volume of depth $N$.
3D convolution on an RGB image
A single filter spans all 3 RGB channels, producing one output feature map by summing contributions from all input channels.
3D filter applied to input tensor
Input volume (H×W×3) convolved with a 3×3×3 filter produces a 2D feature map. N filters produce an output of depth N.

Dimensions and Parameter Count

Example ValuesFormula
Input volume$H \times W \times d_{\text{in}}$Given
Each filter shape$k_h \times k_w \times d_{\text{in}}$Depth must equal $d_{\text{in}}$
Output volume$H' \times W' \times N$$N$ = number of filters
Parameters per filter$k_h \times k_w \times d_{\text{in}} + 1$Including bias
Total parameters$N \times (k_h \times k_w \times d_{\text{in}} + 1)$
Parameter count example: 32×32×3 input, 16 filters of 3×3

Parameters = $16 \times (3 \times 3 \times 3 + 1) = 16 \times 28 = 448$

Compare to FC layer: $32 \times 32 \times 3 \times 16 = 49{,}152$ weights — over 100 times more.

This dramatic reduction is why CNNs can be trained on modest hardware and generalize well.

5. Pooling Layers

After convolution extracts local features, pooling layers reduce spatial resolution while increasing the effective receptive field of later layers.

Why Pooling?

  1. Reduce spatial resolution: Decreases computation in subsequent layers.
  2. Increase receptive field: Later filters see larger regions, detecting higher-level patterns.
  3. Partial translation/scale invariance: Small input shifts do not change pooling output.
CNN receptive field and pooling structure
After pooling, subsequent convolution filters have larger effective receptive fields, allowing detection of larger patterns.

Max Pooling

The most common pooling operation: a window slides over each feature map and selects the maximum value at each position.

Max Pooling: 2×2 window, stride 2
Input (4×4)Output (2×2)
1  1  2  4
5  6  7  8
3  2  1  0
1  2  3  4
6  8
3  4
Top-left: max(1,1,5,6)=6   Top-right: max(2,4,7,8)=8   Bottom-left: max(3,2,1,2)=3   Bottom-right: max(1,0,3,4)=4
Max pooling 2x2 example
Max pooling with 2×2 window and stride 2: halves spatial dimensions in both axes.

Average Pooling

$$\text{AvgPool}(i, j) = \frac{1}{p^2} \sum_{m=0}^{p-1} \sum_{n=0}^{p-1} \text{input}(i \cdot s + m, \; j \cdot s + n)$$
PropertyMax PoolingAverage Pooling
What it preservesStrongest activation (dominant feature)Overall activation level
EffectSharpens feature responsesSmooths feature responses
Typical useClassification CNNs (most common)Final layers (e.g., Global Average Pooling)
Learnable parametersNoneNone
Channel mixingNo (operates independently per channel)No (operates independently per channel)
Max pooling vs average pooling comparison
Comparison of max pooling (preserves strongest activations) and average pooling (smooths responses).
Spatial reduction through convolution and pooling
Convolution followed by pooling: spatial dimensions shrink progressively (11×11 → 9×9 → 3×3).
Pooling Operations Visualizer

6. The Full CNN Pipeline

Standard Architecture Pattern

$$\text{Input} \rightarrow [\text{Conv} + \text{ReLU} \rightarrow \text{Pool}]_{\times k} \rightarrow \text{Flatten} \rightarrow [\text{FC} + \text{ReLU}]_{\times m} \rightarrow \text{Softmax} \rightarrow \text{Output}$$
Full CNN architecture pipeline
Complete CNN pipeline: Input image → stacked Conv+Pool layers → FC layers → Softmax → class probabilities.

Role of Each Stage

StageFunctionWhat It Learns
Early conv layersLow-level feature detectionEdges, lines, corners (like learned Sobel filters)
Middle conv layersMid-level feature detectionTextures, simple shapes, combinations of edges
Deep conv layersHigh-level feature detectionObject parts, complex patterns (semantically meaningful)
Pooling layersSpatial reduction, abstractionProgressive summarization; larger receptive fields
FC layersCombine all features for classificationDecision making
SoftmaxConvert raw scores to probabilitiesCalibrated probability distribution over classes
CNN classification pipeline with class probabilities
Example CNN classification: boat (0.94), cat (0.04), bird (0.02), dog (0.01). The softmax output is a probability distribution over all classes.

Example: 125×125×3 Input Network

StageOutput Dimensions
Input$125 \times 125 \times 3$
Conv1 + Pool1$62 \times 62 \times 32$
Conv2 + Pool2$31 \times 31 \times 64$
Conv3 + Pool3$15 \times 15 \times 64$
Conv4 + Pool4$7 \times 7 \times 16$
Flatten$784 \times 1$
FC1$16 \times 1$
Output (Softmax)$5 \times 1$ (5 classes)

Key pattern: Spatial dimensions decrease while depth (number of channels) increases as you go deeper. This represents progressive transformation from raw pixels to abstract, high-level features.

CNN Layer-by-Layer Builder

7. 1×1 Convolution

As networks grow deeper, the number of feature maps (channels) grows rapidly. 1×1 convolutions are used to reduce or expand the number of channels without affecting spatial dimensions.

1×1 Convolution
A 1×1 filter with shape $1 \times 1 \times d_{\text{in}}$ computes a weighted sum across all input channels at each spatial position. With $d_{\text{out}}$ such filters, the output has $d_{\text{out}}$ channels. Spatial receptive field is not affected — the filter mixes information across channels, not spatially.
1x1 convolution reducing 192 channels to 64
1×1 convolution: reduces 192 channels to 64 while preserving H×W dimensions.
Example: Channel compression from 192 to 64

Input: $64 \times 64 \times 192$ (192 feature maps)

1×1 conv: 64 filters of size $1 \times 1 \times 192$

Output: $64 \times 64 \times 64$ (64 feature maps)

Parameters: $64 \times (1 \times 1 \times 192 + 1) = 64 \times 193 = 12{,}352$

Compare to 3×3 conv: $64 \times (3 \times 3 \times 192 + 1) = 110{,}656$ parameters — nearly 9 times more expensive.

1×1 convolutions are used extensively in GoogLeNet/Inception (channel bottleneck before 3×3 and 5×5 convs) and ResNet bottleneck blocks.

8. Stride, Padding, and Output Size

Stride

Stride is the step size the filter moves between positions.

Stride 1 vs stride 2 comparison
Stride 1 on a 5×5 input with 3×3 filter: 3×3 output. Stride 2: 2×2 output.

Padding

Padding adds extra pixels (typically zeros) around the input border before convolution.

TypeDescriptionOutput Size
Valid padding (no padding)Filter only slides where it fully fits. Output smaller than input.$(W - K + 1) \times (W - K + 1)$
Same padding (zero padding)Zeros added so output has same spatial dimensions as input.$W \times W$ (same as input)
Zero-padding example
Zero-padding: a 6×6 input padded to 8×8, convolved with 3×3 kernel (stride 1), produces a 6×6 output (same dimensions).
Why padding matters
Without padding, each convolution layer shrinks spatial dimensions. After many layers, feature maps become too small. Padding preserves spatial information, especially at the borders (border pixels would otherwise contribute to fewer outputs), and enables building deeper networks.

Output Size Formula

Output Spatial Dimension
$$O = \left\lfloor \frac{W - K + 2P}{S} \right\rfloor + 1$$ where $W$ = input size, $K$ = kernel size, $P$ = padding, $S$ = stride.
$W$$K$$P$$S$$O$Note
3230130Shrinks
3231132Same size
3252132Same size
3230215Halved (approx.)
224732112AlexNet first layer
CNN Output Size Calculator

9. Overfitting and Regularization

The Bias-Variance Tradeoff

Underfitting, just right, and overfitting
Three model complexity regimes: underfitting (too simple), just right (optimal capacity), overfitting (too complex).
Bias-variance tradeoff curve
Total generalization error = Bias + Variance. Optimal capacity minimizes both. Underfitting = high bias. Overfitting = high variance.

L1 and L2 Regularization

Regularization penalizes large weight values, encouraging simpler models that generalize better.

Regularized Cost Function
$$\text{Cost} = \mathcal{L}(\theta) + \lambda \cdot R(\theta)$$ where $\lambda$ is the regularization strength hyperparameter.
TypePenalty TermFull CostEffect
L1 (Lasso)$\sum |w_i|$$\mathcal{L}(\theta) + \lambda \sum |w_i|$Drives some weights to exactly zero; sparse model; feature selection
L2 (Ridge / Weight Decay)$\sum w_i^2$$\mathcal{L}(\theta) + \lambda \sum w_i^2$Drives weights toward small values; smooth decision boundaries
Effect of regularization on decision boundaries
Decision boundaries: linear (0.83 train acc, too simple), NN without regularization (0.89, jagged/overfitting), NN with regularization (0.87, smooth/generalizable).
Key insight
Regularization slightly reduces training accuracy but improves validation accuracy. A small training-validation gap with slightly lower training accuracy is preferable to a model that memorizes training data.

10. Dropout

Dropout randomly disables neurons during each training iteration with probability $p$ (typically $p = 0.5$).

Dropout: standard network vs network after dropout
Standard network (left) vs. network with dropout applied (right). Crossed-out neurons are disabled for this iteration.
TrainingInference
NeuronsEach has probability $p$ of being set to zeroAll neurons active
WeightsOnly active neurons' weights are updatedScaled by $(1-p)$ to compensate

Why Dropout Works

Practical Notes
  • Typically applied to fully connected layers, not convolutional layers.
  • Common rates: $p = 0.5$ for hidden layers, $p = 0.2$ for input layers.
  • Never apply dropout during inference.

11. Batch Normalization

The Problem: Internal Covariate Shift

During training, the distribution of each layer's inputs changes as parameters in preceding layers change. Each layer must continuously adapt to a shifting input distribution, slowing training. This is called internal covariate shift.

The Algorithm

Batch Normalization Steps
Given mini-batch $\mathcal{B} = \{x_1, \ldots, x_m\}$:
  1. Compute batch mean: $\mu_{\mathcal{B}} = \frac{1}{m} \sum_{i=1}^{m} x_i$
  2. Compute batch variance: $\sigma_{\mathcal{B}}^2 = \frac{1}{m} \sum_{i=1}^{m} (x_i - \mu_{\mathcal{B}})^2$
  3. Normalize: $\hat{x}_i = \frac{x_i - \mu_{\mathcal{B}}}{\sqrt{\sigma_{\mathcal{B}}^2 + \epsilon}}$
  4. Scale and shift: $y_i = \gamma \hat{x}_i + \beta$
$\gamma$ (scale) and $\beta$ (shift) are learnable parameters trained via backpropagation.
Batch normalization placement in neuron pipeline
BatchNorm placement: Linear → BatchNorm → Activation (most common) or Linear → Activation → BatchNorm.
Batch normalization algorithm
BatchNorm: normalize to zero mean and unit variance, then apply learned scale (gamma) and shift (beta).
Batch normalization distribution shift
The input distribution is normalized, then re-scaled and re-shifted by learned gamma and beta parameters.

Benefits

BenefitExplanation
Faster convergenceAllows higher learning rates without instability
Reduced sensitivity to initializationNormalized inputs are less sensitive to the starting weight values
Mild regularizationMini-batch statistics introduce noise that acts like dropout
Gradient stabilityReduces vanishing/exploding gradient risk
Inference behavior
At test time, there is no mini-batch. BatchNorm uses running averages of $\mu$ and $\sigma^2$ accumulated during training (exponential moving averages). The $\gamma$ and $\beta$ parameters remain as trained.

12. Weight Initialization and Transfer Learning

Initialization Schemes

SchemeFormulaBest For
Gaussian (random)$w \sim \mathcal{N}(0, \sigma^2)$ fixed $\sigma$Simple baseline; often suboptimal
Xavier / Glorot$w \sim \mathcal{N}\!\left(0, \frac{2}{n_{\text{in}} + n_{\text{out}}}\right)$Sigmoid / Tanh activations
MSRA / He$w \sim \mathcal{N}\!\left(0, \frac{2}{n_{\text{in}}}\right)$ReLU activations
Pretrained weightsLoad from model trained on large datasetAlways preferred when available

Transfer Learning

Use a model pretrained on a large dataset (e.g., ImageNet, 1.2M images) as the starting point for a new task.

  1. Take a pretrained network (e.g., ResNet on ImageNet).
  2. Freeze early layers — they already learn generic features (edges, textures, colors).
  3. Replace and retrain the final FC layers for your specific task (different number of output classes).
  4. Optionally fine-tune some later convolutional layers with a very small learning rate.
Why transfer learning works
Early CNN layers learn generic features (edges, textures) useful for almost any visual task. Only deeper layers learn task-specific features. Starting from pretrained weights provides a massive head start and allows training on small datasets that would otherwise cause overfitting.

13. Gradient Descent Variants and Optimizers

Variants of Gradient Descent

VariantGradient computed overSpeedStability
Batch GDEntire datasetSlowVery stable
Stochastic GD (SGD)Single sampleFast per updateOscillating
Mini-batch GDBatch of $n$ samplesGood balanceGood balance

Mini-batch GD is the standard in practice. Typical batch sizes: 32, 64, 128 images.

Momentum

Standard GD oscillates in narrow valleys or gets stuck in local minima. Momentum accumulates velocity from previous updates:

Gradient Descent with Momentum
$$v_t = \gamma \cdot v_{t-1} + \eta \cdot \nabla_{\theta} J(\theta)$$ $$\theta = \theta - v_t$$ where $\gamma \approx 0.9$ is the momentum coefficient. Dampens oscillations; accelerates progress in consistent directions.
Gradient descent with and without momentum
Without momentum: oscillating, slow. With momentum: smoother path, faster convergence. Think of a ball rolling down a hill accumulating speed.

Advanced Optimizers

OptimizerKey Idea
NAG (Nesterov)"Look-ahead" momentum: computes gradient at anticipated future position
AdaGradAdapts learning rate per parameter; decreasing rate based on sum of past squared gradients
RMSpropLike AdaGrad but uses exponential moving average of squared gradients (fixes diminishing rate)
AdamCombines momentum (first moment) + RMSprop (second moment). Most popular in practice.
Optimizer comparison on 3D loss surface
Optimizer convergence paths on a 3D loss surface. Adam typically converges fastest and most reliably.
Optimizer comparison on 2D contour plot
2D contour view: different optimizers trace different paths to the minimum. Adaptive methods (Adam, RMSprop) generally outperform vanilla SGD.
Practical recommendation
Adam is the safe default choice for most CNN training tasks. Adaptive methods (Adam, RMSprop, Adadelta) generally outperform vanilla SGD. Start with a learning rate between $10^{-3}$ and $10^{-4}$, and reduce it after training plateaus.
Training tips: learning rate, initialization, general advice
  • Learning rate: Start low ($10^{-3}$ to $10^{-8}$). Reduce after thousands of iterations. Too high = oscillating loss. Too low = slow decrease.
  • Weight initialization: Always prefer pretrained weights. Use Xavier for sigmoid/tanh, MSRA/He for ReLU.
  • Monitor both training and validation loss to detect overfitting early.
  • Use pretrained models at least for earlier layers — they extract generic features useful for any visual task.
  • CNNs can be difficult to train. If stuck, reduce the learning rate or check data preprocessing.

14. What Does a CNN See? Feature Map Visualization

Visualizing CNN feature maps reveals the hierarchical nature of learned representations:

CNN feature map visualization
Feature maps from early layers (top) show edge detectors in various orientations. Deeper layers (bottom) show increasingly abstract patterns.
Hierarchical feature learning in CNN layers
Layer 1: edges and orientations. Layer 2: simple shapes and parts. Layer 3: whole face structures. Each layer builds on the previous.
$$\text{Pixels} \xrightarrow{\text{Conv1}} \text{Edges} \xrightarrow{\text{Conv2}} \text{Textures} \xrightarrow{\text{Conv3}} \text{Parts} \xrightarrow{\text{Conv4}} \text{Objects} \xrightarrow{\text{FC}} \text{Class}$$
3D feature map visualizations
3D feature map visualizations: early layers show clear spatial structure; deeper layers show more abstract, less human-interpretable patterns.
CNN architecture with labeled stages
Labeled CNN stages: prediction/error, feature extraction, hierarchical feature extraction, cross-feature map learning, classification.

15. Classification Metrics

Confusion Matrix

Confusion Matrix
Predicted: YesPredicted: No
Actual: YesTP (True Positive)FN (False Negative)
Actual: NoFP (False Positive)TN (True Negative)
Classification threshold with TP and FP regions
Sorted prediction scores with a threshold: above threshold = predicted positive (TP if correct, FP if wrong); below = predicted negative.

Core Metrics

Accuracy, Precision, Recall, F1
$$\text{Accuracy} = \frac{TP + TN}{TP + TN + FP + FN}$$ $$\text{Precision} = \frac{TP}{TP + FP} \quad \text{("of all predicted positive, how many were right?")}$$ $$\text{Recall (TPR)} = \frac{TP}{TP + FN} \quad \text{("of all actual positive, how many did we find?")}$$ $$F_1 = 2 \cdot \frac{\text{Precision} \cdot \text{Recall}}{\text{Precision} + \text{Recall}}$$

The Problem with Accuracy

Accuracy is misleading for imbalanced datasets. Example: 9,990 Class 0 samples, 10 Class 1 samples. A model predicting everything as Class 0 achieves 99.9% accuracy while completely failing to detect any Class 1 samples.

Key insight
Never use accuracy alone with imbalanced datasets. Use precision, recall, and F1. The harmonic mean in F1 penalizes extreme imbalances between precision and recall more than the arithmetic mean would.

Precision-Recall Tradeoff

Threshold directionPrecisionRecall
Raise threshold (more selective)Increases (fewer FP)Decreases (more FN)
Lower threshold (more inclusive)Decreases (more FP)Increases (fewer FN)

PR Curve and ROC Curve

Precision-Recall curve
PR curve: sweeping threshold from 0 to 1 traces the precision-recall tradeoff. Ideal curve stays near the top-right corner (high precision AND recall).
PR AUC example
PR-AUC = area under the PR curve. Higher = better. Random classifier baseline depends on class ratio (not 0.5 as in ROC).
ROC Curve
Plots TPR (= Recall) on y-axis vs. FPR = $\frac{FP}{FP + TN}$ on x-axis.
  • Perfect classifier: top-left corner (TPR=1, FPR=0)
  • Random classifier: diagonal line (ROC-AUC = 0.5)
  • Any curve above the diagonal is better than random
ROC curve comparison
ROC curves: perfect classifier (top-left), better model (green), worse model (orange), random classifier (diagonal).
ROC curve with threshold sweep
ROC curve with threshold sweep: each point corresponds to a different classification threshold.
MetricROC CurvePR Curve
Best forBalanced datasetsImbalanced datasets
Random baselineDiagonal (AUC = 0.5)Depends on class ratio
Sensitive to imbalance?Less sensitiveMore sensitive (more informative)
EmphasizesOverall discriminationPerformance on positive (minority) class

Application-Driven Metric Selection

ApplicationPriority MetricThreshold SettingReason
Tumor detection (medical)High RecallLow (more inclusive)Missing a tumor is life-threatening
Spam detection (email)High PrecisionHigh (more selective)Misclassifying important email is costly
Balanced applicationF1 Score0.5 (default)Equal weight to precision and recall
PR curves from 10-fold cross-validation
PR curves from 10-fold cross-validation. Low variance across folds indicates a reliable, generalizable model.

Flashcards