The Palos Publishing Company

Follow Us On The X Platform @PalosPublishing
Categories We Write About

How to Identify Data Outliers Using Robust Methods in EDA

Exploratory Data Analysis (EDA) is a crucial step in understanding data before applying any modeling or statistical techniques. Identifying outliers is one of the fundamental tasks during EDA because outliers can significantly distort statistical summaries and affect the performance of machine learning models. Traditional methods to detect outliers often rely on assumptions about data distribution, such as normality, which may not hold true in many real-world datasets. This is where robust methods come into play — they are designed to identify outliers effectively even when data deviate from common assumptions or contain noise.

What Are Data Outliers?

Outliers are observations that differ significantly from the majority of the data. They may result from errors, rare events, or genuine variability in the data. Detecting outliers is essential because:

  • They can skew mean and standard deviation.

  • They may indicate data quality issues.

  • They might reveal important insights, such as fraud or rare events.

Limitations of Traditional Outlier Detection Methods

Common techniques like Z-score or methods based on mean and standard deviation assume that the data are normally distributed. For example, points beyond 3 standard deviations from the mean are often flagged as outliers. However:

  • If the data distribution is skewed or multimodal, these methods fail.

  • Outliers can distort mean and standard deviation themselves, leading to inaccurate detection.

  • Sensitivity to outliers causes masking (outliers hide each other) or swamping (normal points flagged as outliers).

To overcome these, robust statistical methods use measures less affected by extreme values, improving outlier identification.


Robust Methods for Outlier Detection in EDA

1. Median and Median Absolute Deviation (MAD)

  • Median is the middle value of the data, which is not affected by extreme values.

  • MAD is the median of the absolute deviations from the median:

    MAD=median(Ximedian(X))MAD = median(|X_i – median(X)|)

To identify outliers using MAD:

Modified Z-score=0.6745×Ximedian(X)MADtext{Modified Z-score} = 0.6745 times frac{X_i – median(X)}{MAD}

Points with a modified Z-score greater than 3.5 are often considered outliers.

Advantages:

  • Works well for skewed data.

  • Resistant to extreme values.

Usage Example:

python
import numpy as np data = np.array([10, 12, 12, 13, 12, 14, 100, 12]) median = np.median(data) mad = np.median(np.abs(data - median)) modified_z_scores = 0.6745 * (data - median) / mad outliers = np.where(np.abs(modified_z_scores) > 3.5)

2. Interquartile Range (IQR) Method

IQR is the difference between the 75th percentile (Q3) and 25th percentile (Q1):

IQR=Q3Q1IQR = Q3 – Q1

Outliers are often defined as values outside the range:

[Q11.5×IQR,Q3+1.5×IQR][Q1 – 1.5 times IQR, quad Q3 + 1.5 times IQR]

For a more robust approach, multipliers other than 1.5 can be used depending on the desired sensitivity.

Advantages:

  • Non-parametric and does not assume data distribution.

  • Simple to implement and interpret.

Limitations:

  • May miss outliers in small datasets or when data is heavily skewed.

3. Robust Covariance Estimation (Minimum Covariance Determinant – MCD)

When dealing with multivariate data, simple univariate methods might miss anomalies that appear only in the joint distribution.

  • The Minimum Covariance Determinant (MCD) estimates the mean and covariance matrix robustly by minimizing the determinant of the covariance of a subset of the data.

  • Mahalanobis distance calculated using MCD parameters identifies outliers considering correlation between variables.

D2=(xμ)TΣ1(xμ)D^2 = (x – mu)^T Sigma^{-1} (x – mu)

Where μmu and ΣSigma are robust estimates from MCD.

Points with large Mahalanobis distances (based on chi-square distribution thresholds) are flagged as outliers.

Advantages:

  • Effective for multivariate outlier detection.

  • Robust against contamination.


4. Robust Principal Component Analysis (RPCA)

In high-dimensional datasets, outliers may be detected more efficiently by reducing dimensionality while maintaining robustness.

  • RPCA separates data into a low-rank matrix (normal data) and a sparse matrix (outliers).

  • The sparse matrix highlights anomalies without being affected by the overall data distribution.


5. Local Outlier Factor (LOF)

Though not purely statistical, LOF is a robust density-based method useful in EDA:

  • It compares the local density of a point to its neighbors.

  • Points with significantly lower density than neighbors are outliers.


Practical Workflow for Outlier Detection Using Robust Methods

  1. Visual Inspection:

    • Boxplots with IQR-based whiskers.

    • Robust scatterplots or projection plots.

  2. Calculate Robust Statistics:

    • Compute median, MAD, IQR.

    • Calculate modified Z-scores or IQR boundaries.

  3. Flag Univariate Outliers:

    • Use MAD or IQR methods to identify points outside thresholds.

  4. Check Multivariate Outliers:

    • Apply robust covariance estimation (MCD) and calculate Mahalanobis distances.

    • Use RPCA or LOF for complex datasets.

  5. Confirm Outliers:

    • Cross-check flagged points visually.

    • Investigate domain knowledge to understand outliers’ origin.


Benefits of Using Robust Methods in EDA

  • Minimize influence of extreme values on summary statistics.

  • Better detection in skewed, heavy-tailed, or contaminated datasets.

  • More reliable initial data cleaning for downstream analysis.

  • Improved insights by distinguishing true anomalies from noise.


Robust outlier detection techniques are essential for reliable EDA, especially with real-world data that rarely follow idealized assumptions. Incorporating methods like MAD, IQR, MCD, and RPCA ensures a balanced and thorough identification of unusual observations, enabling data scientists to build cleaner, more accurate models and uncover hidden insights.

Share this Page your favorite way: Click any app below to share.

Enter your email below to join The Palos Publishing Company Email List

We respect your email privacy

Categories We Write About