Data Analysis
Welcome to the world of the data. Here, I will share some basics of data analysis and some methods. Let’s discover:
What are Outliers?
An outlier is a data point that significantly deviates from the rest of the data. Outliers can arrise due to:
- Errors in data entry or measurement.
- Rare events or legitimate extremes (market anomalies, luxury home prices)
- Observations from a different distribution than the majority (fraud detection scenarious)
Outliers Detection with IQR (Interquantile range) Method
Why choose the IQR Method?
Many traditional techniques rely on the assumption of the normality like Z scores or the 3-sigma rule which unreliable when dealing with skewed data. The IQR method is non-parametric and makes no assumptions about distribution shape, making it inherently more robust. It is ideal for distributions with long tails, skew or multiple peaks.
Understanding Box Plots and Percentiles
A box plot visualizes distribution by indicating:
- Q1(25th Percentile): 25% of the data falls below this point.
- Median / Q2 (50th Percentile): The middle of the data.
- Q3 (75th Percentile): 75% of data falls below this point.
The Interquantile Range (IQR) captures the middle 50%:
Using the IQ, outliers are identified via the IQR proximity rule, which defines:
- Lower Bound: Q1–1,5 * IQR
- Upper Bound: Q3 + 1,5 * IQR
Any data point outside this range is considered an outlier.
NOTE: The multiplier 1,5 is a convention that balances sensitivity and robustness across domains. (Rule of thumb)
Why This Works
- Distribution-agnostic: Works well regardless of skew or modality.
- Resistent to extremes: Since it is based on percentiles, extreme values have minimal impact on Q1 and Q3.
- Simple and Interpretable: Easy to compute, explain and justify.
It is totally up to you removing outliers or not. They can be just noise or represent a key point for data. The choice depends on the usage of the data.
Summary for IQR
- The IQR method is powerful for skewed data like house precies, salaries, or medical costs.
- Outliers can be either removed or capped depending on the analysis context.
- Always visualize before and after applying IQR filtering to make informed decisions.
Z and Advanced Z Score
If we study statistic , I have to mention Z score here:
Z Score
The Z-score measures how many standard deviations each value in the data is from the mean.
The generally accepted rule in statistics is as follows: If a data point’s Z-score is less than -3 or greater than +3, that value is an outlier and falls outside the top 99.7 percent of the normal distribution.
Get Taha Soylu’s stories in your inbox
Join Medium for free to get updates from this writer.
WARNING: The Z score considers your data bell like. If your data is skewed, you may need to advanced techniques.
MAD (Median Absolute Deviation)
The classic Z-score uses standard deviation to measure how widely the data is spread. Instead, we will use a much more robust measure called the Median Absolute Deviation (MAD).
To find the MAD, you calculate how much each value in the data set deviates from the overall median, and then take the median of those deviations.
Mi: Advanced Z score
xi: The actual value of the data currently analyzed
x~: The median of the whole column
MAD: Median Absolute Deviation
0.6745: This value is a statistical constant used to ensure that the result can be expressed on the same scale as the classical standard deviation.
Correlation Matrix
A correlation matrix is a table showing correlation coefficients between variables. Each cell in the table shows the relationship between two specific variables. It acts as an X-ray for your dataset, allowing you to instantly spot which features move together, which move in opposite directions and which are completely independent.
Reading the Scale
The default metric used in these matrices is the Pearson Correlation Coefficient denoted mathematically by r. The value of r always falls strictly between -1 and 1.
+1 (Perfect Positive Correlation):
As variable A goes up, variable B goes up in a perfectly predictable perfect line.
-1 (Perfect Negative Correlation):
Variable A goes up, variable B goes down.
0 (Non Linear Correlation):
The variables have absolutely no linear relationship. They are essentially random noise to each other.
The Diagonal: It is always filled with 1 because a variable is perfectly correlated with itself.
Why it is crucial for Machine Learning?
- If you feed a predictive model two features that are highly correlated (r > 0.85) you are essentially giving the model the same information twice. This called MULTICOLLINARITY. It confuses linear models, artificially inflates variance and slows down training.
- If you are trying to predict a specific target you look at the correlation between the target and all the other features. Features with a high absolute correlation to your target are your “golden features” and must be kept.
- Correlation does not imply causation: Just because ice cream sales and shark attacks are highly correlated does not mean eating ice cream causes shark attacks. They are both driven by a hidden third value (summer weather).
Data Analysis is finished. You may continue with Time Series Feature Engineering.










