Machine Learning Associate ยท Exploring and preparing data
Visualizing and comparing features
Choosing plots for categorical and continuous features, and the right method to compare two categorical (contingency table, chi-square) or two continuous features (scatter plot, correlation).
Key points
- One categorical feature: bar chart of category counts.
- One continuous: histogram for shape, box plot for spread and outliers.
- Two categorical: contingency table (df.crosstab) and chi-square test of independence.
- Two continuous: scatter plot plus correlation coefficient (Pearson linear, Spearman monotonic).
- A coefficient near zero only rules out a linear relation, so always check the scatter plot.
Practice questions
Which plot best shows the distribution (shape) of a single continuous feature?
- Histogram
- Contingency table
- Scatter plot of the feature against itself
- Pie chart of the raw values
Show answer
Answer: A. Histogram
A histogram bins the values and shows skew, modes and spread. A bar chart of counts suits categories, and a scatter plot needs two variables.
Which are appropriate ways to compare two continuous features?
- A scatter plot of one against the other
- Pearson correlation coefficient for a linear relationship
- Spearman rank correlation for a monotonic but non-linear relationship
- A contingency table with a chi-square test on the raw values
- A single histogram, which quantifies the correlation between them
Show answer
Answer: A. A scatter plot of one against the other, B. Pearson correlation coefficient for a linear relationship, C. Spearman rank correlation for a monotonic but non-linear relationship
Scatter plots, Pearson (linear) and Spearman (monotonic) all fit two continuous variables. Contingency tables with chi-square are for categorical pairs, and a histogram shows only one variable.
True or false: a Pearson correlation close to 0 proves that two continuous features are unrelated.
Show answer
Answer: False
False. Pearson measures only linear association. A U-shaped or other non-linear pattern can have r near 0 while the features are strongly related, which a scatter plot reveals.
Practice 8 questions on this topic in Bitzu
Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.
