Challenge - 5 Problems
Distribution Plot Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of histplot with bins parameter
What is the output of this code snippet that uses seaborn's histplot with bins=3 on a small dataset?
Data Analysis Python
import seaborn as sns import matplotlib.pyplot as plt data = [1, 2, 2, 3, 4, 5] sns.histplot(data, bins=3) plt.close() # Prevent plot display in test environment counts = [3, 1, 2] # Expected counts per bin print(counts)
Attempts:
2 left
💡 Hint
Bins split the data range into equal parts; count how many values fall into each bin.
✗ Incorrect
The data values are split into 3 bins: [1-2], (2-3.666], (3.666-5]. The counts per bin are 3, 1, and 2 respectively.
❓ data_output
intermediate2:00remaining
KDE plot density estimate values
Given this code using seaborn kdeplot on a small dataset, what is the approximate density estimate at x=2.0?
Data Analysis Python
import seaborn as sns import numpy as np import matplotlib.pyplot as plt data = [1, 2, 2, 3, 4] kde = sns.kdeplot(data, bw_adjust=0.5) plt.close() # Approximate density at x=2.0 is printed below from scipy.stats import gaussian_kde kde_scipy = gaussian_kde(data, bw_method=0.5 * np.std(data, ddof=1)) density_at_2 = kde_scipy.evaluate(2.0)[0] print(round(density_at_2, 2))
Attempts:
2 left
💡 Hint
KDE smooths data points; density is higher near repeated values.
✗ Incorrect
The density estimate peaks near repeated values like 2, and with bw_adjust=0.5, the density at 2 is about 0.75.
🔧 Debug
advanced2:00remaining
Identify error in histplot usage
What error does this code raise when trying to plot a histogram with seaborn histplot?
Data Analysis Python
import seaborn as sns data = [1, 2, 3, 4] sns.histplot(data, bins='five')
Attempts:
2 left
💡 Hint
Check the type and value of the bins parameter.
✗ Incorrect
The bins parameter expects an integer or a sequence of bin edges, not a string like 'five'.
❓ visualization
advanced2:00remaining
Effect of bandwidth on KDE plot shape
Which option best describes the effect of increasing the bandwidth parameter in seaborn's kdeplot on the shape of the density curve?
Attempts:
2 left
💡 Hint
Bandwidth controls smoothing; higher means more smoothing.
✗ Incorrect
Increasing bandwidth smooths the KDE curve more, making it wider and less detailed.
🧠 Conceptual
expert2:00remaining
Choosing between histplot and kdeplot for data analysis
Which statement best explains when to prefer seaborn's kdeplot over histplot for visualizing data distribution?
Attempts:
2 left
💡 Hint
Think about smoothness and binning in distribution plots.
✗ Incorrect
KDE plots provide a smooth curve estimating the probability density function, avoiding bin edges and counts.