Databricks Machine Learning Associate · Section 2 · 19% of the exam
Compare two categorical or two continuous features using the appropriate method
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
Before choosing an imputation strategy, a data scientist wants to see whether the continuous feature delivery_hours is skewed. Which visualization is most appropriate?
- AA pie chart of the delivery_hours values
- BA bar chart with one bar per distinct delivery_hours value
- CA counter visualization that shows the average delivery_hours across all orders
- DA histogram of delivery_hours with a suitable number of bins
Show the answer
D. A histogram groups a continuous feature into bins and plots how often values fall into each, which reveals the shape of the distribution: symmetric, right-skewed or left-skewed, plus any isolated extreme values. A box plot is a good companion chart. Bar and pie charts are meant for categorical data.
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
- Create visualizations for categorical or continuous features
- 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