Study guide
2.2 Creating Visualizations for Categorical and Continuous Features
Databricks Certified Machine Learning Associate Study Guide Exam
Track your progress as you read
Finished sections get a check mark.
1 Chapter 1: Databricks Machine Learning (38% of the Exam)
1.1 MLOps Best Practices on Databricks 1.2 Advantages of Databricks ML Runtimes and Compute Selection 1.3 Promoting Code vs. Promoting Models 1.4 How AutoML Facilitates Model and Feature Selection 1.5 AutoML Advantages in the Model Development Process 1.6 Feature Tables in Unity Catalog vs. the Workspace Feature Store 1.7 Creating a Feature Table and Writing Data to It 1.8 Training a Model with Features from a Feature Table 1.9 Scoring a Model with Features from a Feature Table 1.10 Online vs. Offline Feature Tables 1.11 Manually Logging Metrics, Artifacts, and Models in an MLflow Run 1.12 Identifying the Best Run with the MLflow Client API 1.13 Information Available in the MLflow UI 1.14 Registering a Model in the Unity Catalog Registry 1.15 Model Tags, Aliases, and Champion/Challenger Promotion
2 Chapter 2: Data Processing and ML Workflows (19% of the Exam)
2.1 Computing Summary Statistics on a Spark DataFrame 2.2 Creating Visualizations for Categorical and Continuous Features 2.3 Comparing Two Categorical or Two Continuous Features 2.4 Removing Outliers with Standard Deviation and IQR 2.5 When Log-Scale Transformation Is Appropriate 2.6 Comparing and Applying Mean, Median, and Mode Imputation 2.7 One-Hot Encoding and When It Is or Is Not Appropriate
3 Chapter 3: Model Development (31% of the Exam)
3.1 Selecting the Appropriate Algorithm for a Scenario 3.2 Methods to Mitigate Data Imbalance in Training Data 3.3 Comparing Estimators and Transformers 3.4 Developing a Training Pipeline 3.5 Tuning Hyperparameters with Hyperopt's fmin 3.6 Grid, Random, and Bayesian Search Strategies 3.7 Parallelizing Single-Node Models for Hyperparameter Tuning 3.8 Cross-Validation vs. a Train-Validation Split 3.9 Counting the Models Trained by Grid Search and Cross-Validation 3.10 Using Common Classification Metrics 3.11 Using Common Regression Metrics 3.12 Choosing the Most Appropriate Metric for the Objective 3.13 Exponentiating Log-Transformed Predictions Before Evaluation 3.14 Model Complexity and the Bias-Variance Tradeoff
4 Chapter 4: Model Deployment (12% of the Exam)
4.1 Differences and Advantages of Batch, Streaming, and Real-Time Serving 4.2 Performing Batch Inference with pandas and Spark UDFs 4.3 Streaming Inference with Delta Live Tables 4.4 Deploying a Custom Model to a Model Endpoint 4.5 Deploying, Querying, and Splitting Traffic Across Real-Time Endpoints
2.2 Creating Visualizations for Categorical and Continuous Features
Key Takeaways Explain This Topic AI
Continuous features are inspected with histograms (shape and modality) and box plots (median, IQR, outliers); categorical features with bar or count charts of level frequency.
display() on any Spark DataFrame renders an interactive table, and the + Visualization control builds bar, line, area, scatter, histogram, box, pie, heatmap, and pivot charts without exporting data.
Aggregation should be pushed into Spark with groupBy().agg() before plotting, because the notebook chart layer works from a bounded number of returned rows.
A grouped box plot — a continuous feature split by a categorical level — is the standard way to see whether a feature separates the target classes.
Plot choice follows feature type: one continuous → histogram or box; one categorical → bar; continuous by categorical → grouped box; continuous by continuous → scatter.
Last updated: August 2026
2.2 Creating Visualizations for Categorical and Continuous Features
Summary statistics tell you the moments of a distribution; a plot tells you its shape . Two columns can share a mean and standard deviation while one is unimodal
and the other bimodal — a difference that changes which model and which preprocessing
are appropriate, and which no summary table will reveal.
Interactive Notebook Visualizations with display()
The native Databricks display() function renders any PySpark DataFrame, Spark SQL query result, or pandas DataFrame into an interactive rich table. From the display() output, users can click the + (Add Visualization) button to launch the Databricks Visualization Editor. # Render interactive table in Databricks notebook
- df_features = spark.sql("""
- SELECT
- customer_id,
- tenure_months,
- monthly_charges,
- total_charges,
- contract_type,
- payment_method,
- churn_label
- FROM ml_catalog.silver_prep.churn_features
- """)
- display(df_features)
- Supported Built-in Visualization Types
Databricks notebook visualizations execute aggregations at the Spark engine level or aggregate client-side depending on sample size:
Bar Charts & Grouped / Stacked Bars : Ideal for comparing category counts, mean target rates across categorical segments (e.g., churn rate by contract_type ), and categorical distributions.
Histograms & Frequency Density Plots : Essential for inspecting numerical distributions, identifying multi-modal clusters, and spotting severe right or left skewness.
Box Plots (Whisker Plots) : Displays the five-number summary (minimum, lower fence Q 1 − 1.5 × I Q R Q1 - 1.5 \times IQR Q 1 − 1.5 × I QR , median, upper fence Q 3 + 1.5 × I Q R Q3 + 1.5 \times IQR Q 3 + 1.5 × I QR , maximum) alongside individual outlier points. Critical for comparing numerical distributions across target classes.
Scatter Plots : Visualizes bivariate relationships between two continuous features (e.g., monthly_charges vs. total_charges ) to detect non-linear dependencies, clustering, or heteroscedasticity.
Line & Area Charts : Used primarily for time-series feature trends, seasonality detection, and monitoring feature value drift over time.
Pivot Tables & Heatmaps : Facilitates two-dimensional cross-tabulations (e.g., average churn rate broken down simultaneously by payment_method and contract_type ).
Matching the Chart to the Question
- What you have What you want to see Chart
- One continuous feature Shape, skew, modality, gaps Histogram
- One continuous feature Median, spread, outliers Box plot
- One categorical feature Level frequencies, rare levels, cardinality Bar / count chart
- One categorical feature, few levels Share of the whole Pie chart (only when levels are few)
- Continuous split by a categorical Whether the feature separates groups Grouped box plot
- Two continuous features Relationship shape, clusters, heteroscedasticity Scatter plot
- Two categorical features Co-occurrence pattern Heatmap over a crosstab
- A continuous feature over time Trend, seasonality, level shifts Line chart
- Reading each one
- Histogram — bin count matters. Too few bins hide bimodality; too many turn the
- distribution into noise. A long right tail with a spike at zero usually means a
count or currency feature, which points at a log-plus-one transform (Section 2.5).
- Box plot — the box spans Q1 to Q3, the line is the median, and the whiskers
- extend to Tukey's 1.5 × IQR fences with points beyond drawn individually. Those
points are exactly the observations Section 2.4's IQR rule flags.
- Bar chart of a categorical — look for a level that dominates (near-constant
- column), a very long tail of rare levels (a one-hot encoding hazard), and case or
whitespace variants of the same value ( "Male" , "male" , " M" ).
Grouped box plot — if the boxes for churned and retained customers overlap
almost completely, that feature carries little univariate signal for the target.
- Aggregate in Spark, Then Plot
- The notebook chart layer works from the rows display() returns, so a plot built
- directly on a billion-row DataFrame is drawn from a bounded slice of it — which
misrepresents the true distribution. Push the aggregation into Spark first: from pyspark.sql import functions as F
- # Correct: Spark computes the aggregate, the chart plots a small result
- churn_by_contract = (
- df.groupBy("contract_type")
- .agg(F.count("*").alias("customers"),
- F.avg("churn_label").alias("churn_rate"))
- .orderBy(F.desc("customers"))
- )
- display(churn_by_contract) # bar chart: contract_type on X, churn_rate on Y
- # Histogram of a continuous feature: bucket in Spark, then plot the counts
- bucketed = (
- df.withColumn("charge_bucket", (F.col("monthly_charges") / 10).cast("int") * 10)
- .groupBy("charge_bucket").count().orderBy("charge_bucket")
- )
- display(bucketed)
- For an unaggregated scatter of a huge table, sample deliberately rather than relying on
truncation: display(df.sample(fraction=0.01, seed=42)) .
- When to Leave the Built-In Charts
- Built-in visualizations cover the common cases without moving data. Reach for
- Matplotlib or Seaborn on a sampled pandas DataFrame when you need a correlation
- heatmap with annotations, a pair plot, overlaid density curves, or any figure you
- intend to log to MLflow with mlflow.log_figure : import seaborn as sns, matplotlib.pyplot as plt
- pdf = df.select("tenure_months", "monthly_charges", "churn_label").sample(0.05, seed=42).toPandas()
- fig, ax = plt.subplots(figsize=(7, 5))
- sns.boxplot(data=pdf, x="churn_label", y="monthly_charges", ax=ax)
- mlflow.log_figure(fig, "eda/charges_by_churn.png")
The rule is unchanged from every other Spark operation: reduce first, collect second. toPandas() on an unsampled large table is the fastest way to an out-of-memory driver.