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.corrsupports 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, plusChiSquareTestfor 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?
- AA scatter plot of the StringIndexer index of neighborhood against price
- BA box plot of price grouped by neighborhood
- CA pie chart of the total price per neighborhood
- 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
- Compute summary statistics on a Spark DataFrame using .summary() or dbutils data summaries
- Remove outliers from a Spark DataFrame based on standard deviation or IQR
- Compare two categorical or two continuous features using the appropriate method
- Compare and contrast imputing missing values with the mean or median or mode value
- Impute missing values with the mode, mean, or median value
- Use one-hot encoding for categorical features
- Identify and explain the model types or data sets for which one-hot encoding is or is not appropriate.
- Identify scenarios where log scale transformation is appropriate