Outliers and Influence

Drag one point around and watch a least-squares line follow it. Twenty-four rows say one thing; the twenty-fifth overrules them.

Outliers and Influence

This module needs JavaScript: the numbers are computed in the page rather than recorded.

Worth knowing

Least squares minimises squared error, so a point twice as far off pulls four times as hard.
An outlier far along the x axis has high leverage: it sits at the end of the lever and moves the line most.
A point can be extreme and correct. Deleting it because it is inconvenient is how findings stop being true.
Trees, medians and quantile regression are robust to outliers. Means, least squares and standard deviations are not.

Overview

A large residual means an outcome is far from the model’s prediction; high leverage means its predictors are unusual. A point is influential if removing it changes the fitted model. These are different properties: an unusual outcome may have little influence, while a high-leverage point can still fit the trend.

In this guide
  1. Three related ideas
  2. Explore the fitted line
  3. Decide what the observation means
  4. More robust alternatives
  5. Common mistakes with Outliers and Influence
  6. Sources and next steps

In least-squares regression, residuals are squared. A point twice as far from the fitted line contributes four times as much squared error. This makes a distant observation capable of pulling the line toward itself.

Explore the fitted line

In the visualizer, move the point vertically while keeping its x-position near the middle, then move it to the edge of the x-range. A point near the mean x has less leverage on the slope; an extreme x-value can rotate the line more. If that edge point also sits far from the trend, it can combine high leverage and a large residual, making it influential.

Cook’s distance combines residual size and leverage to estimate how much a fitted regression would change if an observation were removed. It is a diagnostic, not an automatic deletion rule; no single cutoff decides whether a row is an error or should be excluded.

Decide what the observation means

  1. Data error: check units, transcription, sensor failures, and sentinel values such as 999. Correct or remove errors and document the choice.
  2. Different population: a wholesale order may not belong in a model for ordinary retail purchases. Decide whether it is outside the question or deserves a separate model.
  3. Valid extreme case: keep it if the model is meant to cover such cases. Compare results with and without it and report sensitivity when conclusions change.

Deleting points simply because they make a fit less convenient changes the population being modeled. Investigate first; if the cause is uncertain, show how the conclusion depends on the point.

More robust alternatives

Huber regression uses squared loss for small residuals and a loss that grows more slowly for large residuals. RANSAC fits candidate models on subsets and selects a consensus set. These methods can reduce sensitivity to some outliers, but they rely on assumptions too and may ignore valid rare cases. Transforming a strongly skewed feature can also help when the scale is the issue.

Common mistakes with Outliers and Influence

  • Deleting every point beyond three standard deviations: the cutoff assumes a distribution and the point can inflate the standard deviation.
  • Confusing unusual x with unusual y: leverage and residuals measure different properties.
  • Treating robust regression as automatic cleanup: inspect which observations receive less influence and why.
  • Ignoring data quality: an impossible value is a data problem before it is a modeling problem.

Sources and next steps

Check yourself

0 of 3

Answer without scrolling back up.

  1. Why does least squares react so strongly to a single distant point?

  2. What makes a point 'influential' rather than merely an outlier?

  3. What is wrong with removing anything beyond three standard deviations?

Cheat sheet

Outliers and Influence

Move one data point and watch the regression line follow it. Use Cook's distance and hat values to find the rows that control your model.

MACHINE LEARNING · vizlearn.in/machine_learning/outliers_and_influence.html

About the author

Ashish Jangra builds and maintains VizLearn. Every module here is written and the visualisation behind it hand-built, so the numbers in a readout come from the same code that draws the picture. Corrections are genuinely welcome and get priority over everything else — if a page states something wrong, or an animation misrepresents what the algorithm does, get in touch.

Teaching a course with this? Individual teachers can use it freely; for a whole department or programme, see institutional licences.