Fixing a Binary Classification Model for Flight Delays
Statistics & ExperimentsModel answerLast updated
Identify and correct statistical errors in a flight delay prediction model, including inappropriate regression choice, feature encoding issues, and data quality problems.
A data science team built a model to predict whether flights will be delayed by more than 15 minutes. They used ordinary least squares (OLS) regression with these features:
day_of_week: encoded numerically as 1 through 7flight_seats: aircraft capacity (contains some negative values from upstream ETL bugs)- Several operational timing variables that are highly correlated with each other
Their target variable is binary: 1 if the flight was delayed more than 15 minutes, 0 otherwise.
Address each of these modeling issues:
1) Model selection: Explain precisely why OLS is unsuitable for this binary target. Recommend an appropriate alternative, stating its distributional family, link function, core assumptions, and practical methods to validate those assumptions.
2) Day-of-week encoding: Demonstrate why treating weekdays as a numeric sequence 1–7 introduces bias. Suggest a better encoding scheme and describe how to statistically test whether day-of-week matters at all.
3) Data integrity: Propose a sound strategy for handling the negative seat counts and any missing data. Discuss how different imputation approaches affect both bias and variance in your coefficient estimates.
4) Correlated predictors: Define the variance inflation factor (VIF) and show mathematically why VIF_j = 1/(1 − R²_j). If one operational variable has VIF = 12, interpret what this means. List three methods to address this issue, explaining the trade-offs of each. Also clarify how feature standardization impacts both coefficient interpretation and multicollinearity detection.
5) Model assessment: Recommend evaluation metrics suitable for a binary outcome with imbalanced classes. Design a cross-validation strategy that prevents temporal information leakage, and explain how to ensure your predicted probabilities are well-calibrated.
Hints
Hint 1
For binary outcomes, consider what happens when a linear model predicts values outside [0,1] and how error variance changes with the prediction
Hint 2
Treating sequential categories as numbers assumes equal spacing and monotonic effects—test whether removing this constraint improves fit
Hint 3
High VIF means a predictor is nearly a linear combination of others; this inflates standard errors but doesn't necessarily hurt predictions
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
Model Answer
This problem requires diagnosing multiple statistical issues in a classification pipeline. I'll address each systematically.
1) Why OLS Fails for Binary Targets
When the outcome Y ∈ {0,1}, ordinary least squares estimates E[Y|X] = X^T β directly. This linear probability model has fundamental flaws:
Range violations: The linear predictor X^T β is unbounded, producing "probabilities" below 0 or above 1 for many feature combinations. These are nonsensical predictions.
Built-in heteroskedasticity: For binary Y, the conditional variance is Var(Y|X) = p(X)[1 − p(X)], which necessarily varies with X. OLS assumes constant variance, so its standard errors are incorrect and it's no longer the most efficient estimator.
Distributional mismatch: Residuals can only take two values for any given X, violating normality assumptions underlying classical inference.
Incorrect marginal effects: OLS imposes constant slopes. In reality, a 10-minute increase in turnaround time has diminishing impact as delay probability approaches 0 or 1.
Recommended alternative: Logistic regression
- Distributional family: Bernoulli, Y_i ~ Bernoulli(p_i)
- Link function: logit, where log(p_i/(1−p_i)) = X_i^T β
- Estimation: Maximum likelihood via iteratively reweighted least squares
- Coefficients represent log-odds ratios
Checking assumptions:
| Assumption | Validation method |
|---|---|
| Log-odds linearity for continuous features | Compare nested models with polynomial or spline terms using likelihood ratio tests; examine binned-logit plots |
| Conditional independence | Check for clustering by airport/date; use cluster-robust standard errors or mixed-effects models if needed |
| No extreme collinearity or separation | Monitor condition number, VIF values, and coefficient magnitudes; watch for warnings during fitting |
| Correct functional form | Plot binned residuals against predicted probabilities; examine calibration curves; compute deviance residuals |
2) Problems with Numeric Day Encoding
Coding weekdays as 1, 2, …, 7 imposes unwarranted structure:
Equal spacing assumption: The model assumes Monday→Tuesday has identical effect as Saturday→Sunday, which is rarely true for flight patterns.
Forced monotonicity: A single slope coefficient cannot capture non-monotonic patterns like weekend peaks or mid-week troughs.
Broken cyclicity: Sunday (7) and Monday (1) are adjacent days but maximally separated numerically.
When the true day effects are non-monotonic, this misspecification creates omitted-variable bias. The unexplained day structure correlates with other features (weekend flights differ in route mix, load factors, etc.), biasing their coefficients as well.
Better approach: One-hot encoding with k−1 dummy variables, leaving one day as the reference category. Each coefficient then represents the log-odds difference relative to the baseline day.
Testing for day effects: Use a likelihood ratio test comparing the full model (with all day dummies) against a reduced model excluding them:
- Test statistic: G = 2(ℓ_full − ℓ_reduced)
- Under the null hypothesis of no day effects: G ~ χ²_6
- Reject if G exceeds the critical value, indicating day-of-week matters
3) Handling Data Quality Issues
Negative seat counts: These are logically impossible, not merely unusual values.
Don't apply absolute value or clip to zero—both inject systematic measurement error. Instead:
- Preferred: Match records to a reference database (aircraft registration → type → configuration) for deterministic correction
- Otherwise: Treat as missing and apply principled imputation
- Always: Track the error rate by carrier and time period; concentrated errors suggest the missingness mechanism is informative
Missing value strategies and their impacts:
| Approach | Bias implications | Variance/SE implications |
|---|---|---|
| Complete-case analysis | Unbiased only if missing completely at random (MCAR); biased under MAR if missingness relates to the outcome | Reduces effective sample size; SEs inflate proportional to √(n/n_complete) |
| Mean substitution | Artificially shrinks feature variance by fraction missing; distorts covariances, biasing coefficients of correlated features | Understates uncertainty—treats imputed values as observed |
| Mean + missingness indicator | Captures informative missingness; partially corrects bias | Better variance properties than mean alone |
| Multiple imputation (MICE) | Nearly unbiased under MAR if imputation model includes outcome and relevant predictors | Correct SEs via Rubin's combining rules accounting for between-imputation variance |
Empirical impact assessment:
- Use complete cases as ground truth
- Artificially introduce missingness under realistic mechanisms
- Apply each strategy and compare coefficient bias, prediction RMSE, and confidence interval coverage
- Critically: Fit imputation models only on training data within each CV fold
4) Multicollinearity and VIF
Definition: VIF_j quantifies how much the variance of coefficient β̂_j is inflated due to linear relationships with other predictors.
Mathematical derivation:
Starting from the OLS variance formula (assuming centered predictors):
Var(β̂_j) = σ² [(X^T X)^−1]_jj
By the Frisch-Waugh-Lovell theorem, β̂_j equals the coefficient from regressing Y on the residuals r̃ from regressing x_j on all other predictors. Thus:
Var(β̂_j) = σ² / Σr̃_i²
Let SS_j = Σ(x_ij − x̄_j)² be the total sum of squares for feature j. The residual sum of squares from the auxiliary regression is:
Σr̃_i² = SS_j(1 − R²_j)
where R²_j measures how well other predictors explain x_j. Substituting:
Var(β̂_j) = σ² / [SS_j(1 − R²_j)]
If x_j were orthogonal to others, R²_j = 0 and Var(β̂_j) = σ²/SS_j. The ratio gives:
VIF_j = 1/(1 − R²_j)
Interpreting VIF = 12:
- R²_j = 11/12 ≈ 0.917: About 92% of the turnaround time variance is explained by other operational features
- The coefficient standard error is √12 ≈ 3.5× larger than if turnaround time were uncorrelated with other predictors
- The coefficient estimate becomes unstable; small data changes cause large swings
- Predictions may remain stable since collinear features move together
Three remediation strategies:
-
Variable selection or combination: Drop redundant features or create domain-informed composites (e.g., "operational complexity index"). Simple and interpretable but risks omitted-variable bias if removed features are true confounders.
-
Principal component analysis: Transform to orthogonal components, eliminating collinearity. However, components lack clear interpretation, and unsupervised PCA may discard directions predictive of Y.
-
Regularization (Ridge/Lasso/Elastic Net): Ridge (L2 penalty) shrinks correlated coefficients toward each other, dramatically reducing variance at the cost of bias. Lasso can arbitrarily select one variable from correlated groups. Requires tuning via cross-validation and complicates classical inference.
Standardization effects:
- Coefficients express "change per standard deviation" rather than per original unit, making magnitudes comparable across features
- Multicollinearity is a property of the correlation structure, so VIF values remain unchanged—standardization is just a linear transformation
- Regularization methods typically require standardization to avoid penalizing features based on their measurement scale
5) Evaluation for Imbalanced Binary Classification
Appropriate metrics:
- Precision and recall: More informative than accuracy when classes are imbalanced
- AUPRC (area under precision-recall curve): Better than AUROC for rare positive class
- Calibration metrics: Expected Calibration Error (ECE), Brier score
- Business-specific: Expected cost using actual delay costs and false alarm costs
Avoid: Raw accuracy (misleading with imbalance), F1 alone (doesn't capture probability calibration)
Time-aware cross-validation:
Use forward-chaining temporal splits to prevent leakage:
- Sort all data chronologically
- Train on months 1–6, validate on month 7
- Train on months 1–7, validate on month 8
- Continue rolling forward
Never shuffle time-series data or use random K-fold CV—the model would "see the future" through correlated temporal patterns, weather, and seasonal effects.
Probability calibration:
After fitting, check calibration by:
- Binning predictions into deciles
- Plotting predicted probability vs. observed frequency in each bin
- If poorly calibrated, apply Platt scaling (fit logistic regression on held-out validation predictions) or isotonic regression
- Re-evaluate calibration on a final test set not used for scaling
Well-calibrated probabilities enable decision-making under uncertainty and are essential when predicted probabilities drive operational decisions.