Bird
Raised Fist0
ML Pythonml~8 mins

Exploratory data analysis in ML Python - Model Metrics & Evaluation

Choose your learning style10 modes available
Metrics & Evaluation - Exploratory data analysis
Which metric matters for Exploratory Data Analysis and WHY

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.

Confusion matrix or equivalent visualization

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
    
Tradeoff: What to focus on during EDA

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.

What "good" vs "bad" looks like in EDA metrics

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.
Common pitfalls in EDA metrics
  • 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.
Self-check question

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.

Key Result
Exploratory Data Analysis focuses on descriptive statistics and visualizations to understand data quality and patterns before modeling.

Practice

(1/5)
1. What is the main goal of exploratory data analysis (EDA) in machine learning?
easy
A. To train the machine learning model
B. To understand the main features and quality of the data
C. To deploy the model to production
D. To write the final report without looking at data

Solution

  1. Step 1: Understand the purpose of EDA

    EDA is used to explore and understand the data before modeling.
  2. Step 2: Differentiate EDA from other steps

    Training and deployment happen after EDA, so they are not the main goal of EDA.
  3. Final Answer:

    To understand the main features and quality of the data -> Option B
  4. Quick Check:

    EDA = Understand data [OK]
Hint: EDA means exploring data, not modeling or deploying [OK]
Common Mistakes:
  • Confusing EDA with model training
  • Thinking EDA is for deployment
  • Skipping data understanding step
2. Which Python library is commonly used for basic exploratory data analysis tasks like viewing data samples and summary statistics?
easy
A. matplotlib
B. tensorflow
C. pandas
D. scikit-learn

Solution

  1. Step 1: Identify libraries for EDA

    Pandas provides functions like head() and describe() for data samples and summary stats.
  2. Step 2: Exclude other libraries

    Matplotlib is for plotting, scikit-learn for modeling, tensorflow for deep learning, not basic EDA.
  3. Final Answer:

    pandas -> Option C
  4. Quick Check:

    pandas = data samples and stats [OK]
Hint: Use pandas for quick data overview and stats [OK]
Common Mistakes:
  • Using matplotlib for data samples
  • Confusing modeling libraries with EDA
  • Trying tensorflow for simple stats
3. Given the following Python code using pandas, what will 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())
medium
A. Summary statistics including count, mean, std, min, max for 'age' and 'score'
B. The first 5 rows of the dataframe
C. A plot showing distribution of 'age' and 'score'
D. An error because describe() needs parameters

Solution

  1. Step 1: Understand what describe() does

    It returns summary statistics like count, mean, std, min, max for numeric columns.
  2. Step 2: Check the code output

    Since 'age' and 'score' are numeric, describe() will show stats for both columns.
  3. Final Answer:

    Summary statistics including count, mean, std, min, max for 'age' and 'score' -> Option A
  4. Quick Check:

    describe() = summary stats [OK]
Hint: describe() shows stats, head() shows rows [OK]
Common Mistakes:
  • Thinking describe() shows data rows
  • Expecting a plot from describe()
  • Assuming describe() needs arguments
4. You run this code but get an error:
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?
medium
A. Error due to None value; fix by using df.mean(skipna=True)
B. Error due to missing import; fix by importing numpy
C. Error due to wrong data type; fix by converting all to strings
D. No error; code runs fine as is

Solution

  1. Step 1: Check how pandas handles None in numeric columns

    Pandas treats None as NaN and by default mean() skips NaN values.
  2. Step 2: Verify if code runs without error

    The code runs fine and calculates mean ignoring None.
  3. Final Answer:

    No error; code runs fine as is -> Option D
  4. Quick Check:

    pandas mean() skips None by default [OK]
Hint: pandas mean() ignores None/NaN by default [OK]
Common Mistakes:
  • Assuming None causes error in mean()
  • Thinking numpy import is needed here
  • Trying to convert numbers to strings
5. You have a dataset with columns age, income, and purchased (Yes/No). Which EDA step helps you find if income affects purchased?
hard
A. Plotting boxplots of income grouped by purchased categories
B. Calculating mean age of all customers
C. Checking for missing values in age column
D. Sorting data by income in ascending order

Solution

  1. Step 1: Identify relationship to explore

    We want to see if income differs between those who purchased and those who did not.
  2. Step 2: Choose appropriate EDA method

    Boxplots grouped by purchased categories show income distribution differences clearly.
  3. Final Answer:

    Plotting boxplots of income grouped by purchased categories -> Option A
  4. Quick Check:

    Boxplots show group differences [OK]
Hint: Use grouped boxplots to compare numeric by category [OK]
Common Mistakes:
  • Ignoring grouping by purchased
  • Checking unrelated columns
  • Just sorting without visualization
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard