Bird
Raised Fist0
ML Pythonml~20 mins

Exploratory data analysis in ML Python - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Exploratory Data Analysis Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ data_output
intermediate
1:30remaining
Calculate the mean and median of a dataset

You have a dataset of ages: [22, 25, 29, 24, 30, 22, 28]. What are the mean and median values?

ML Python
import numpy as np
ages = [22, 25, 29, 24, 30, 22, 28]
mean_age = np.mean(ages)
median_age = np.median(ages)
print(f"Mean: {mean_age}, Median: {median_age}")
AMean: 25.0, Median: 25.71
BMean: 25.71, Median: 24.0
CMean: 24.0, Median: 25.71
DMean: 25.71, Median: 25.0
Attempts:
2 left
💡 Hint

Mean is the average, median is the middle value when sorted.

❓ visualization
intermediate
2:00remaining
Identify the correct histogram plot for given data

Given the data points: [1, 2, 2, 3, 3, 3, 4, 4, 5], which histogram correctly shows the frequency of each number?

ML Python
import matplotlib.pyplot as plt
import numpy as np
data = [1, 2, 2, 3, 3, 3, 4, 4, 5]
plt.hist(data, bins=5, edgecolor='black')
plt.show()
ABar heights: 1=1, 2=2, 3=3, 4=2, 5=1
BBar heights: 1=2, 2=1, 3=3, 4=1, 5=2
CBar heights: 1=1, 2=3, 3=2, 4=2, 5=1
DBar heights: 1=1, 2=2, 3=2, 4=3, 5=1
Attempts:
2 left
💡 Hint

Count how many times each number appears.

🧠 Conceptual
advanced
1:30remaining
Understanding correlation coefficients

Which statement correctly describes a Pearson correlation coefficient of -0.85 between two variables?

AStrong positive linear relationship
BWeak negative linear relationship
CStrong negative linear relationship
DNo linear relationship
Attempts:
2 left
💡 Hint

Correlation values near -1 or 1 indicate strong relationships.

🔧 Debug
advanced
1:30remaining
Identify the error in this code for calculating variance

What error will this code raise?

import numpy as np
data = [1, 2, 3, 4, 5]
variance = np.var(data, ddof=1)
print(variance)
ML Python
import numpy as np
data = [1, 2, 3, 4, 5]
variance = np.var(data, ddof=1)
print(variance)
ASyntaxError due to missing parenthesis
BTypeError because ddof is invalid
CNameError because variance is undefined
DNo error, prints variance
Attempts:
2 left
💡 Hint

Check the parentheses in the function call.

🚀 Application
expert
2:00remaining
Determine the number of clusters from a silhouette score plot

You run k-means clustering on a dataset with k values from 2 to 6. The silhouette scores are: {2: 0.45, 3: 0.52, 4: 0.48, 5: 0.40, 6: 0.35}. Which k should you choose for best cluster separation?

Ak = 2
Bk = 3
Ck = 4
Dk = 5
Attempts:
2 left
💡 Hint

Higher silhouette score means better cluster separation.

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