Skip to main content

ML & AI in Databricks Dashboards

🧩 1. Introduction to ML & AI in Dashboards

🌍 Modern Story Way

Imagine your dashboard as a mirror.

A normal mirror shows you what you look like right now. But what if your mirror also told you:

✨ “You might smile tomorrow.” ✨ “Your mood will dip next week; take a break.” ✨ “Your energy level is trending up — keep going!”

This is exactly what Databricks dashboards do when you add Machine Learning (ML) and Artificial Intelligence (AI).

Instead of just showing what happened, your dashboards begin to show:

  • 📈 What will happen next (sales forecasts)
  • 🕵️ What’s unusual (customer anomalies)
  • 🛒 What you should do next (product recommendations)

Your dashboard becomes a living assistant, not a static report.


💼 Professional Explanation

Integrating ML and AI into Databricks dashboards adds layers of intelligence such as:

  • Predictive Analytics – forecasting sales, churn, demand, risk
  • Anomaly Detection – spotting outliers or unusual activity
  • Decision Automation – recommending actions based on data
  • Natural Language Insights – using LLMs to generate summaries

Databricks supports an end-to-end ML workflow using:

  • MLflow – model tracking, metrics, artifacts
  • Databricks Feature Store – centralized feature management
  • AutoML – automated model training
  • Databricks Model Serving – deploy models as APIs
  • Dashboards – visualize insights in realtime

📸 Example Visual - Databricks ML Pipeline Flow

![Databricks Dashboard Example](./img/databricks-dashboard-ml-example.png)
Databricks ML Pipeline FlowDataFeature StoreAutoMLMLflow RegistryDashboards

🚀 MLflow Overview

🌍 Modern Story Way

Think of MLflow as your machine-learning diary — a notebook that never forgets.

A data scientist may test 10… 20… or 200 models:

  • “This model got 92% accuracy.”
  • “This one used XGBoost with learning_rate=0.1.”
  • “Run #74 is the best — lowest error.”

MLflow writes everything down automatically.

It’s like a chef keeping a recipe book:

🍲 “This was the best dish — here’s exactly how I made it.”

Whenever you need to recreate or deploy the model — MLflow already saved the recipe.


💼 Professional Explanation

MLflow is an open-source platform integrated into Databricks for managing the ML lifecycle.

It includes 4 major components:

1️⃣ MLflow Tracking

Simple Explanation: MLflow Tracking is like a notebook that automatically records everything about your machine-learning experiments — what parameters you used, how well the model performed, and what files it created.

Why it matters: It helps you compare models, remember what you did, and pick the best version without confusion.

Example Code:

import mlflow

with mlflow.start_run():
mlflow.log_param("model_type", "xgboost")
mlflow.log_metric("rmse", 3.21)

2️⃣ MLflow Projects

Simple Explanation: MLflow Projects is a way to package your machine-learning code, environment, and dependencies so you or your team can run the same experiment anywhere — with one command.

Why it matters: It eliminates “it works on my machine” problems by ensuring the code behaves the same everywhere (laptop, Databricks, cluster, or cloud).


3️⃣ MLflow Models

Simple Explanation: MLflow Models stores your trained models in a standard, portable format so they can be deployed easily to different places (APIs, batch jobs, cloud services).

Why it matters: No matter how a model was trained — in Python, R, Scikit-learn, PyTorch, etc. — MLflow wraps it so other tools can use it without compatibility issues.


4️⃣ MLflow Model Registry

Simple Explanation: The Model Registry is a central “library shelf” where all your models are stored, versioned, reviewed, and approved for production.

Why it matters: It provides governance:

  • You can track versions (v1, v2, v3…)
  • Add comments/review notes
  • Approve/reject models
  • Deploy to production with a click

It keeps your ML workflow organized and safe.

📊 How MLflow Helps Dashboards

You can use MLflow to:

  • Fetch the latest best model run
  • Display model accuracy trends in the dashboard
  • Show how performance improves over time

Example snippet to load the best model:

from mlflow import MlflowClient

client = MlflowClient()
best_run = client.search_runs(
experiment_ids=["12345"],
order_by=["metrics.rmse ASC"],
max_results=1
)[0]

best_run.info.run_id

📸 MLflow UI Example Placeholder - MLflow Tracking System Concept

![MLflow Tracking UI Example](./img/mlflow-ui-example.png)
MLflow Tracking OverviewExperiment RunsRun IDParametersMetricsArtifacts#74model=xgbrmse=3.21model.pklMetrics Over TimeParameterslearning_rate: 0.1max_depth: 5

📘 Why MLflow Matters for Dashboards

🎯 Simple Example

Use Case: Predict next week’s product demand.

Without MLflow:

  • You forget which model was best
  • Hard to reproduce results
  • No version control

With MLflow:

  • Best model is automatically tracked
  • Code + parameters are saved
  • Easy to deploy that model into the dashboard


🛠 Hands-On Example (Simple)

Below is a simple, beginner-friendly Databricks notebook-style demo.

Step 1: Load Data

df = spark.read.format("delta").load("/mnt/data/sales")
display(df)

Step 2: AutoML Training (No ML Expertise Required)

from databricks.automl import regression

summary = regression.train(
df,
target_col="weekly_sales",
timeout_minutes=10
)

summary.best_trial

Step 3: Register the Best Model

summary.register_model(model_name="sales_forecast_model")

Step 4: Create a Dashboard Cell

from pyspark.sql.functions import current_date

model = mlflow.pyfunc.spark_udf(spark, "models:/sales_forecast_model/Production")

predictions = df.withColumn("predicted_sales", model(*df.columns))
display(predictions)

Step 5: Add to Databricks Dashboard

  1. Run the cell
  2. Click “Add to Dashboard”
  3. Choose your dashboard
  4. Set refresh schedule (e.g., every hour)

📸 Dashboard Visualization Placeholder - ML Dashboard Concept

![Predicted vs Actual Chart](./img/predicted-vs-actual-sales.png)
Machine Learning DashboardPrediction TrendAnomalyModel InsightsModel: XGBoostRMSE: 3.21Key KPIsAccuracy: 92%Forecast Horizon: 7 days

1-Minute Summary

TopicModern StoryProfessional
ML & AI in Dashboards“Mirror predicting tomorrow”Predictive / anomaly / automated insights
MLflow“Machine-learning diary”Tracking, projects, models, registry
Why MLflowAvoid forgetting experimentsModel governance + reproducibility
Hands-onSimple AutoML exampleDashboard integration