Exploratory Data Analysis (EDA) is about understanding your data before building models. It does not use accuracy or precision because it is not about predictions yet. Instead, key metrics are descriptive statistics like mean, median, standard deviation, and counts of missing values. These help you see data quality, distribution, and patterns. Knowing these helps you decide how to clean and prepare data for modeling.
Exploratory data analysis in ML Python - Model Metrics & Evaluation
EDA uses visual tools instead of confusion matrices. Common visuals include:
- Histograms: Show how data values spread.
- Box plots: Show data spread and outliers.
- Scatter plots: Show relationships between two variables.
- Missing value heatmaps: Show where data is missing.
Example histogram for ages in a dataset:
Age Distribution
|****
|*******
|*********
|*****
|**
0 10 20 30 40 50
During EDA, you balance between:
- Detail: Looking deeply at each feature to find issues.
- Speed: Quickly getting a general sense of data.
For example, spending too long on one feature might delay your project. But missing important data problems can cause bad models later. So, use summary stats first, then dig deeper where needed.
Good EDA results show:
- Clear understanding of data types and distributions.
- Identification of missing or strange values.
- Insight into relationships between variables.
Bad EDA results miss these, leading to surprises later like:
- Models failing due to unseen missing data.
- Wrong assumptions about data shape.
- Ignoring outliers that skew results.
- Ignoring missing data: Not checking for or handling missing values.
- Overlooking outliers: Not spotting extreme values that affect analysis.
- Assuming normal distribution: Many stats assume data is normal, but real data often isn’t.
- Data leakage: Using future information unknowingly during EDA.
- Confirmation bias: Only looking for patterns you expect, missing surprises.
Your dataset has 20% missing values in a key feature, but you ignore it during EDA. Later, your model performs poorly. What went wrong?
Answer: Ignoring missing data during EDA means you missed cleaning or imputing it. This caused the model to get bad or incomplete information, hurting performance. Good EDA would catch this early.
Practice
exploratory data analysis (EDA) in machine learning?Solution
Step 1: Understand the purpose of EDA
EDA is used to explore and understand the data before modeling.Step 2: Differentiate EDA from other steps
Training and deployment happen after EDA, so they are not the main goal of EDA.Final Answer:
To understand the main features and quality of the data -> Option BQuick Check:
EDA = Understand data [OK]
- Confusing EDA with model training
- Thinking EDA is for deployment
- Skipping data understanding step
Solution
Step 1: Identify libraries for EDA
Pandas provides functions likehead()anddescribe()for data samples and summary stats.Step 2: Exclude other libraries
Matplotlib is for plotting, scikit-learn for modeling, tensorflow for deep learning, not basic EDA.Final Answer:
pandas -> Option CQuick Check:
pandas = data samples and stats [OK]
- Using matplotlib for data samples
- Confusing modeling libraries with EDA
- Trying tensorflow for simple stats
print(df.describe()) output?import pandas as pd
data = {'age': [25, 30, 22, 40, 28], 'score': [88, 92, 85, 95, 90]}
df = pd.DataFrame(data)
print(df.describe())Solution
Step 1: Understand what
It returns summary statistics like count, mean, std, min, max for numeric columns.describe()doesStep 2: Check the code output
Since 'age' and 'score' are numeric,describe()will show stats for both columns.Final Answer:
Summary statistics including count, mean, std, min, max for 'age' and 'score' -> Option AQuick Check:
describe() = summary stats [OK]
- Thinking describe() shows data rows
- Expecting a plot from describe()
- Assuming describe() needs arguments
import pandas as pd
data = {'age': [25, 30, None, 40], 'score': [88, 92, 85, 95]}
df = pd.DataFrame(data)
print(df.mean())What is the likely cause and fix?
Solution
Step 1: Check how pandas handles None in numeric columns
Pandas treats None as NaN and by defaultmean()skips NaN values.Step 2: Verify if code runs without error
The code runs fine and calculates mean ignoring None.Final Answer:
No error; code runs fine as is -> Option DQuick Check:
pandas mean() skips None by default [OK]
- Assuming None causes error in mean()
- Thinking numpy import is needed here
- Trying to convert numbers to strings
age, income, and purchased (Yes/No). Which EDA step helps you find if income affects purchased?Solution
Step 1: Identify relationship to explore
We want to see if income differs between those who purchased and those who did not.Step 2: Choose appropriate EDA method
Boxplots grouped by purchased categories show income distribution differences clearly.Final Answer:
Plotting boxplots of income grouped by purchased categories -> Option AQuick Check:
Boxplots show group differences [OK]
- Ignoring grouping by purchased
- Checking unrelated columns
- Just sorting without visualization
Ready to prove it?
Pass the test and this pattern moves unknown
