
Dan Patiño
AI Strategy & Innovation at Coderhouse
Data
An outlier is a data point that sits far away from the rest of the values in a dataset. It can be a typo, a broken sensor, a fraudulent transaction, or a genuinely rare event that tells you something important. Outliers matter because a handful of extreme values can pull an average, stretch a chart, and quietly change the conclusion of an analysis.
Why it matters now: analysts work with more automated data than ever, from event tracking to IoT feeds to records generated by AI pipelines. More automation means more chances for bad values to slip in unnoticed, and more dashboards and models that inherit them. Knowing how to detect outliers, and deciding what to do with them, is one of the most practical skills in data analysis.
What counts as an outlier?
There is no single universal definition. An outlier is always “far” relative to something: the spread of the data, the expected range of a measurement, or the behavior of similar records. The NIST/SEMATECH e-Handbook of Statistical Methods describes outliers as observations that deviate markedly from other members of the sample, and it stresses that identifying them is the start of an investigation, not the end.
It helps to separate three kinds:
Errors: values that are simply wrong, like an age of 340 or a price entered in cents instead of dollars.
Rare but real events: a record sales day, a viral post, a customer who buys a hundred units at once.
Contextual outliers: values that are normal in one context and strange in another, like heavy website traffic at 3 a.m. for a local business.
Why outliers distort analysis
The mean is very sensitive to extreme values. Imagine nine customers who spend around $50 and one who spends $5,000. The average jumps to roughly $545, a number that describes none of them. The median, by contrast, stays close to $50. Outliers also inflate the standard deviation, compress the rest of a chart into a thin band, and can drag a regression line toward a single point. If you need a refresher on these measures, see our guide to statistics for data analysts.
How analysts detect outliers
1. Look at the data first
Box plots, histograms, and scatter plots reveal most problems faster than any formula. A box plot in particular is built around outlier detection: points drawn beyond the whiskers are flagged automatically.
2. The IQR rule
The interquartile range (IQR) is the distance between the 25th percentile (Q1) and the 75th percentile (Q3). A common rule flags any value below Q1 − 1.5 × IQR or above Q3 + 1.5 × IQR. Because it relies on percentiles, it works well with skewed data such as revenue or session duration.
3. Z-scores
A z-score measures how many standard deviations a value is from the mean. Values with an absolute z-score above 3 are often treated as suspicious. The catch: z-scores assume roughly normal data, and the outliers themselves inflate the standard deviation they are measured against. A more robust variant uses the median and the median absolute deviation (MAD) instead.
4. Business rules
Sometimes domain knowledge beats statistics. A negative quantity, a delivery date before the order date, or a discount above 100% is an outlier by definition, no math needed.
5. Machine learning methods
When you have many variables at once, a value can look normal in every single column and still be unusual as a combination. Algorithms like Isolation Forest, Local Outlier Factor, and One-Class SVM handle these multivariate cases. The scikit-learn documentation on novelty and outlier detection compares these methods side by side, and IBM’s overview of outlier detection explains where each fits.
What to do once you find them
Detection is the easy part. The decision is what to do next, and it should always be documented.
Fix: if the value is a clear error and the correct value is recoverable, correct it at the source.
Remove: if it is an error that cannot be fixed, exclude it, and note how many rows you dropped and why.
Cap (winsorize): replace extreme values with a chosen percentile, such as the 1st and 99th, so they still count but cannot dominate.
Transform: a log transformation can tame long-tailed variables like income or order value.
Keep and report separately: if the outlier is real, it may be the most interesting finding. Fraud, top customers, and system failures all show up as outliers.
Use robust statistics: report the median and percentiles instead of the mean when extremes are expected.
Most of this work happens during data cleaning. For a hands-on walkthrough, read our step-by-step guide to data cleaning with Python and pandas.
Outliers and AI
Outliers affect machine learning models too. A few extreme values in training data can skew a model, while unusual inputs in production can produce unreliable predictions. That is why anomaly detection is a core part of monitoring data pipelines and AI systems: an outlier today can be the first sign of a broken integration tomorrow.
Frequently asked questions
Should I always remove outliers?
No. Remove only values you can show are errors. Real extreme values often carry the most business insight, and deleting them can hide fraud, top customers, or operational problems.
Is the IQR rule better than z-scores?
For skewed data, usually yes, because it does not depend on the mean and standard deviation. For roughly normal data, both work. Many analysts check both and then look at the flagged rows manually.
What is the difference between an outlier and an anomaly?
The terms overlap. “Outlier” is common in statistics and describes a value far from the rest. “Anomaly” is common in monitoring and machine learning and usually implies unexpected behavior worth investigating.
Keep learning
Handling messy, real-world data is a skill you build with practice. If you want structured, project-based training in data and AI, explore these programs:
I'm Dan Patiño, head of AI Strategy & Innovation at Coderhouse. My day-to-day work involves merging the tactical management of e-commerce (CRO, Email Marketing and SEO) with the development of disruptive solutions. I specialize in building internal AI-powered apps to automate tasks and boost innovation within the team. I firmly believe that technology is strategy's best ally. To dive deeper into my professional journey, I'll be waiting for you on my LinkedIn profile.