CertLumen

Databricks Machine Learning Associate · Section 2 · 19% of the exam

Create visualizations for categorical or continuous features

One of the objectives of the Databricks Certified Machine Learning Associate exam, in the section “Data Processing”. Here is what it covers, the points to remember and a question to try.

What it covers

Choose the right chart for categorical and continuous features, compare two continuous features with scatter plots and correlation and two categorical features with contingency tables and the chi-square test, and recognize when a log transform makes a skewed feature or target easier to model.

Points to remember

  • One categorical feature: bar chart of counts. One continuous feature: histogram or box plot.
  • Categorical versus continuous: box plot per category.
  • Two continuous features: scatter plot plus correlation. Pearson measures linear association; Spearman uses ranks and is robust to outliers.
  • df.stat.corr supports only Pearson; pyspark.ml.stat.Correlation.corr(df, vecCol, 'spearman') gives a Spearman matrix.
  • Two categorical features: df.stat.crosstab(c1, c2) as a heatmap or stacked bar, plus ChiSquareTest for independence.

Try a question

A data scientist wants to compare the distribution of price across the five values of neighborhood, including the median and the outliers in each group. Which visualization fits best?

  1. AA scatter plot of the StringIndexer index of neighborhood against price
  2. BA box plot of price grouped by neighborhood
  3. CA pie chart of the total price per neighborhood
  4. DA line chart of price ordered by neighborhood name
Show the answer

B. A box plot per category is the standard way to compare a continuous feature across the levels of a categorical feature. Each box shows the quartiles, the line inside it is the median, and points beyond the whiskers (1.5 x IQR) are outliers, so groups can be compared side by side. Databricks notebook visualizations include a box chart, and seaborn's boxplot works on a pandas sample.

Written for practice in the style of the exam: never a question from the real exam.

In the course

The lesson Visualizing, Comparing and Log-Transforming Features teaches this objective (about 40 minutes), and 16 practice questions test it. The course has lessons, exam-style questions, timed practice exams and an AI tutor for every objective, and a pass prediction that tells you when you're ready to book.

More in this section

← Previous objective · All 48 objectives · Next objective →