Bitzu

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

Single choice

Which plot best shows the distribution (shape) of a single continuous feature?

  1. Histogram
  2. Contingency table
  3. Scatter plot of the feature against itself
  4. 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.

Select all that apply

Which are appropriate ways to compare two continuous features?

  1. A scatter plot of one against the other
  2. Pearson correlation coefficient for a linear relationship
  3. Spearman rank correlation for a monotonic but non-linear relationship
  4. A contingency table with a chi-square test on the raw values
  5. 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

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.

Download on the App StoreGet it on Google Play

More Machine Learning Associate topics in this module