← All Posts
Machine Learning · Regression · Linear Regression· Part 11 of 12

Linear Regression Production Failure Modes

A linear model is easy to score, but the surrounding system can still fail. Wrong feature timing, changed units, missing values, schema mismatches, feedback loops, and population drift can make correct coefficients produce bad predictions.

Leakage and Invalid Validation

Leakage occurs when training uses information that will not exist at prediction time. Examples include future aggregates, post-outcome status codes, and preprocessing fitted on the full timeline. Random splits also leak when related rows from the same person, device, or future period appear on both sides.

Removing the target column is not enough. Leakage checks must follow when and how every feature was created.

Train-Serve Skew and Schema Drift

FailureObservable symptomGuardrail
Unit changePrediction scale jumps while row counts remain normalUnit-bearing schema and range contract
Feature reorderPlausible but systematically wrong scoresName-based binding and artifact hash
Missing default changeError concentrated in sparse cohortsShared transform and missingness indicators
Category remapCoefficient attaches to the wrong levelVersioned vocabulary and unknown bucket policy
Precision lossNear-collinear terms become unstableTyped serialization and score parity tests

Preprocessing is part of the model. Means, scales, clipping rules, category order, interactions, and intercept policy must be versioned with the coefficients. Offline and online scoring should be compared on normal, missing, boundary, unseen-category, and extreme rows.

Extrapolation and Support

A linear formula keeps producing numbers outside the training range, but the relationship may not remain linear there. Prediction uncertainty grows as a row moves away from the training design.

Trap. Checking each feature range separately can miss a new combination of otherwise familiar values. Leverage, Mahalanobis distance, or density checks can detect this joint novelty.

Extrapolation and Drift

▶ A Linear Model Leaves Its Training Range

The model is fitted only on $x=0,\ldots,4$ from the curved process $y=2+x+0.25x^2$. Each step moves farther outside that range and updates both prediction error and a live drift score.

Drift, Feedback, and Silent Degradation

Covariate drift changes the input distribution. Concept drift changes the relationship between inputs and outcomes. Label shift changes outcome frequency. Input drift may be harmless when the relationship stays stable, while concept drift can damage performance even when feature averages look normal.

Predictions may also change future training data. Forecasts affect inventory, risk scores affect approvals, and interventions affect outcomes. Retraining on this selected data can reinforce the old policy unless treatment and eligibility are recorded.

Concrete Monitoring and Retraining Triggers

Monitoring needs several signals. Feature-distribution tests detect input drift. Residual trends detect concept drift after labels arrive. Missingness and range checks detect upstream problems. Latency and fallback rates detect serving failures. Cohort metrics reveal failures hidden by an overall average.

Trigger typeConcrete conditionTypical response
Schedule-basedFixed calendar interval, for example weeklyRoutine retrain regardless of alerts
Drift-basedPSI or KS statistic exceeds a set level, for example PSI $>0.2$Investigate before retraining; drift alone does not confirm harm
Performance-basedRolling validation metric degrades beyond a tolerance bandPrioritized retrain or rollback
Volume-basedEnough freshly labeled, unbiased data has accumulatedRetrain only if the new data avoids feedback selection

A performance drop does not automatically mean retraining is safe. New labels may come from a population selected by the current model. Data quality and representativeness should be checked before retraining.

Numerical and Operational Failures

Collinearity can change coefficients sharply while old-range predictions remain similar. Systems that use coefficient signs or magnitudes therefore need rank, condition, norm, and sign-change checks in addition to RMSE.

Non-finite values, overflow, parsing differences, and schema mismatches need explicit rejection or a documented fallback. Monitoring should begin with immediate schema checks, then prediction-distribution checks, and finally delayed residual and business metrics.

Incident Triage Workflow

A fixed response order prevents rushed retraining from making the incident worse.

  1. Detection: identify the alert source, affected traffic, and start time.
  2. Severity: separate immediate serving failures from gradual statistical degradation.
  3. Containment: use a previous model, fallback, or conservative rule where necessary.
  4. Diagnosis: compare schemas, versions, deployments, upstream feeds, and feature distributions.
  5. Resolution: choose rollback, hotfix, or retraining based on the identified cause.
  6. Verification: use canary traffic and offline-online parity checks before full rollout.
  7. Review: record the cause and add the missing monitor or safeguard.

Important edge cases include constant targets, absent categories, all-zero weights, unlabeled new cohorts, delayed outcomes, and coefficients paired with the wrong preprocessing version. A model package should be atomic, versioned, and reversible.

The C++ linear overview defines the scoring contract, while the C++ diagnostics guide implements metrics and influence checks.