Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Performance Evaluation

1. Model Selection and Hyperparameter Tuning

Underfitting vs. Overfitting

ConditionTraining ErrorTest ErrorCause
UnderfittingHighHighModel too simple
OverfittingLowHighModel too complex

The goal is to choose a model with appropriate complexity that generalizes well to new data.

Hyperparameter Tuning

Hyperparameters control the learning process or model complexity (e.g., polynomial degree, tree depth, regularization CC, learning rate). They must be chosen before training.

Bad ideas:

  1. Tuning on the entire dataset — no independent evaluation left.

  2. Tuning on the test set — the test error is no longer an unbiased estimate.

Good idea: Split data into training, validation, and test sets.


2. Cross-Validation

Hold-out Validation

Split data into training / validation / test sets. The result may depend strongly on the particular split.

K-fold Cross-Validation

  1. Split the training data into KK roughly equal folds.

  2. For each trial k=1,…,Kk = 1, \dots, K: train on all folds except kk, validate on fold kk.

  3. Average the validation performance over all KK trials.

  4. Choose hyperparameters with the best average validation performance.

Practical considerations:


3. Evaluation Metrics for Regression

MetricFormulaProperties
MSE1n∑i=1n(yi−y^i)2\frac{1}{n} \sum_{i=1}^{n} (y_i - \hat{y}_i)^2Penalizes large errors more heavily
MAE$\frac{1}{n} \sum_{i=1}^{n}y_i - \hat{y}_i

4. Evaluation Metrics for Classification

Confusion Matrix

For binary classification (positive / negative):

Predicted PositivePredicted Negative
Actual PositiveTrue Positive (TP)False Negative (FN)
Actual NegativeFalse Positive (FP)True Negative (TN)

Basic Metrics

Accuracy=TP+TNTP+TN+FP+FN\text{Accuracy} = \frac{TP + TN}{TP + TN + FP + FN}

However, accuracy can be misleading for imbalanced classes.

Rate-based Metrics

For the positive class:

TPR (Recall)=TPTP+FN,FNR=FNTP+FN\text{TPR (Recall)} = \frac{TP}{TP + FN}, \quad \text{FNR} = \frac{FN}{TP + FN}

For the negative class:

TNR=TNFP+TN,FPR=FPFP+TN\text{TNR} = \frac{TN}{FP + TN}, \quad \text{FPR} = \frac{FP}{FP + TN}

Note: TPR+FNR=1\text{TPR} + \text{FNR} = 1 and TNR+FPR=1\text{TNR} + \text{FPR} = 1.

Balanced accuracy: TPR+TNR2\frac{\text{TPR} + \text{TNR}}{2}

Precision and Recall

Precision=TPTP+FP,Recall=TPTP+FN\text{Precision} = \frac{TP}{TP + FP}, \quad \text{Recall} = \frac{TP}{TP + FN}

Cost-Sensitive Evaluation

When different mistakes have different importance, assign weights Cp,p,Cn,n,Cp,n,Cn,pC_{p,p}, C_{n,n}, C_{p,n}, C_{n,p}:

Cost-weighted accuracy=Cp,pTP+Cn,nTNCp,pTP+Cn,nTN+Cp,nFN+Cn,pFP\text{Cost-weighted accuracy} = \frac{C_{p,p} TP + C_{n,n} TN}{C_{p,p} TP + C_{n,n} TN + C_{p,n} FN + C_{n,p} FP}

5. ROC Curve and AUC

Operating Points and Thresholds

A classifier outputs scores; a decision threshold τ\tau separates predicted positive from negative. By varying τ\tau, we obtain different trade-offs between FPR and FNR. Each choice of τ\tau is called an operating point.

DET Curve

Plot FNR (y-axis) vs. FPR (x-axis) for all thresholds. A better classifier has a DET curve closer to the bottom-left corner.

ROC Curve

Plot TPR = 1−FNR1 - \text{FNR} (y-axis) vs. FPR (x-axis) for all thresholds. A better classifier has an ROC curve closer to the top-left corner (high TPR, low FPR).

Equal Error Rate (EER): The point where FPR=FNR\text{FPR} = \text{FNR}.

AUC (Area Under the ROC Curve)

AUC provides an overall measure of classifier performance across all possible thresholds.

Interpretation: AUC is the probability that a randomly chosen positive sample receives a higher score than a randomly chosen negative sample.

AUC=P(s+>s−)\text{AUC} = P(s^+ > s^-)

where s+s^+ and s−s^- are scores of randomly drawn positive and negative samples.

Empirical AUC Formula

Given m+m_+ positive samples and m−m_- negative samples with classifier scores g(x)g(x). Define:

eij=g(xi+)−g(xj−)e_{ij} = g(x_i^+) - g(x_j^-)
u(e)={1,e>00.5,e=00,e<0u(e) = \begin{cases} 1, & e > 0 \\ 0.5, & e = 0 \\ 0, & e < 0 \end{cases}
AUC^=1m+m−∑i=1m+∑j=1m−u(eij)\widehat{\text{AUC}} = \frac{1}{m_+ m_-} \sum_{i=1}^{m_+} \sum_{j=1}^{m_-} u(e_{ij})

This is the fraction of positive-negative pairs that are correctly ranked by the classifier.

AUC ranges: