← Back to list

Predictive vs. Descriptive Analytics: When to Use Which?

A Hands-On Guide to Using SQL, Python, and BI Tools to Move from Reporting to Forecasting.

Maximilian Oliver in T3CH · 2025-08-27 16:48 · 63 claps · 3.7 min read paywalled
#predictive-analytics #descriptive-analytics #data-analytics
Open on Medium ↗
Wiki topics: GRW · Growth & Analytics AIM · AI in Marketing

Predictive vs. Descriptive Analytics: When to Use Which?

A Hands-On Guide to Using SQL, Python, and BI Tools to Move from Reporting to Forecasting.

Descriptive analytics tells you what happened, while predictive analytics tells you what’s likely to happen next.

Most teams get stuck in descriptive land — building dashboards, counting KPIs, slicing and dicing. Predictive analytics feels like a leap. But if you’re fluent in SQL, comfortable in Python, and can think in questions, you’re ready.

This guide walks through how I implement both forms of analytics in real-world scenarios. We’ll use SQL for descriptive work and Python (with scikit-learn and statsmodels) for predictive modeling. Each section includes one large code block and no fluff — just applied analytics.

1. Descriptive Analytics with SQL: The Foundation Layer

The first step in any analytics system is building a clear, repeatable, descriptive layer.

-- Daily user activity report
SELECT
    DATE(created_at) AS activity_date,
    COUNT(DISTINCT user_id) AS daily_active_users,
    COUNT(*) AS total_events
FROM events
WHERE created_at >= CURRENT_DATE - INTERVAL '30 days'
GROUP BY 1
ORDER BY 1;

📊 This powers your dashboard. But it only answers: “What happened yesterday?”

2. Feature Engineering for Predictive Modeling

Before we predict anything, we need a feature matrix — one row per user, one column per signal.

import pandas as pd
from sqlalchemy import create_engine

# Connect to warehouse
engine = create_engine("postgresql://user:pass@localhost:5432/mydb")

# Pull behavior data
query = """
SELECT
    user_id,
    COUNT(*) FILTER (WHERE event_type = 'login') AS num_logins,
    COUNT(*) FILTER (WHERE event_type = 'purchase') AS num_purchases,
    MAX(created_at) AS last_seen
FROM events
GROUP BY user_id;
"""
df = pd.read_sql(query, engine)

# Convert last_seen into recency
df['recency_days'] = (pd.Timestamp.now() - df['last_seen']).dt.days

Now you have something that looks like a dataset — and not just a report.

3. Descriptive Analytics with Grouped Aggregates

Want to know which segments behave differently? Break it down by categories.

-- Compare behavior by subscription tier
SELECT
    plan,
    COUNT(DISTINCT user_id) AS users,
    AVG(session_duration) AS avg_session,
    SUM(CASE WHEN made_purchase THEN 1 ELSE 0 END) * 1.0 / COUNT(*) AS conversion_rate
FROM session_logs
GROUP BY plan
ORDER BY conversion_rate DESC;

🧠 This answers: “Which user groups are most engaged or valuable?”

4. Building a Predictive Churn Model

Let’s move from “what’s happening” to “who’s likely to churn.” A logistic regression is a great baseline.

from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
from sklearn.metrics import classification_report

# Assume df contains features + churn column
X = df[['num_logins', 'num_purchases', 'recency_days']]
y = df['churned']  # 1 = churned, 0 = retained

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)

model = LogisticRegression()
model.fit(X_train, y_train)

preds = model.predict(X_test)
print(classification_report(y_test, preds))

Now your dashboard doesn’t just report churn — it predicts it.

5. Time Series Forecasting with ARIMA

Need to forecast revenue or usage? Time series models like ARIMA can be surprisingly effective.

from statsmodels.tsa.arima.model import ARIMA
import matplotlib.pyplot as plt

# Load monthly revenue data
query = """
SELECT
    DATE_TRUNC('month', created_at) AS month,
    SUM(amount) AS revenue
FROM orders
GROUP BY 1
ORDER BY 1;
"""
df = pd.read_sql(query, engine)
df.set_index('month', inplace=True)

model = ARIMA(df['revenue'], order=(1, 1, 1))
fit = model.fit()
forecast = fit.forecast(steps=6)

df['revenue'].plot(label='Observed')
forecast.plot(label='Forecast', style='--')
plt.legend()
plt.show()

🎯 Use this for forecasting server load, demand, or budgets.

6. Building a Self-Updating Descriptive Dashboard

BI tools like Superset or Metabase can read from views or materialized views.

CREATE VIEW user_engagement_summary AS
SELECT
    user_id,
    COUNT(*) FILTER (WHERE event_type = 'login') AS logins,
    COUNT(*) FILTER (WHERE event_type = 'purchase') AS purchases,
    MAX(created_at) AS last_activity
FROM events
GROUP BY 1;

With this view, your dashboard auto-refreshes daily — no ETL required.

7. Visualizing Predictive Output with Python

Once the model is trained, visualize what matters — feature importance and confusion matrix.

import seaborn as sns
from sklearn.metrics import confusion_matrix
import matplotlib.pyplot as plt

# Feature importance
importance = model.coef_[0]
features = X.columns

sns.barplot(x=importance, y=features)
plt.title("Feature Importance for Churn Prediction")
plt.show()

# Confusion matrix
cm = confusion_matrix(y_test, preds)
sns.heatmap(cm, annot=True, fmt='d')
plt.title("Churn Confusion Matrix")
plt.xlabel("Predicted")
plt.ylabel("Actual")
plt.show()import seaborn as sns
from sklearn.metrics import confusion_matrix
import matplotlib.pyplot as plt

# Feature importance
importance = model.coef_[0]
features = X.columns

sns.barplot(x=importance, y=features)
plt.title("Feature Importance for Churn Prediction")
plt.show()

# Confusion matrix
cm = confusion_matrix(y_test, preds)
sns.heatmap(cm, annot=True, fmt='d')
plt.title("Churn Confusion Matrix")
plt.xlabel("Predicted")
plt.ylabel("Actual")
plt.show()

These visualizations become part of your analytics story — not just numbers.

8. Choosing Between Descriptive and Predictive in Practice

When should you use descriptive analytics?

  • Stakeholder wants a snapshot or regular update
  • You’re defining KPIs or health metrics
  • You’re debugging pipeline/data issues

When should you use predictive analytics?

  • You need to act before an event happens (e.g., churn)
  • You want to allocate resources (e.g., fraud review)
  • You want to forecast trends (e.g., revenue next month)

Often, the two go hand-in-hand — descriptive analytics builds trust, predictive analytics drives strategy.

Final Thoughts: Analytics is a Spectrum — Use Both Ends

You don’t have to pick sides. Great analytics teams start with a solid descriptive layer and evolve toward predictive, using:

  • SQL for KPIs, segmentation, filtering
  • Python for feature engineering, modeling, forecasting
  • BI tools to expose insights with minimal friction

It’s not about tools — it’s about asking better questions and building systems that answer them before anyone asks.

Let me know if you want a full example using Metabase dashboards + scikit-learn models + cron-based model retraining — happy to share the workflow I use with clients.


메타데이터
post_id
00ddbcfc2585
slug
predictive-vs-descriptive-analytics-when-to-use-which-00ddbcfc2585
url
https://medium.com/h7w/predictive-vs-descriptive-analytics-when-to-use-which-00ddbcfc2585
canonical_url
https://medium.com/h7w/predictive-vs-descriptive-analytics-when-to-use-which-00ddbcfc2585
author_url
https://medium.com/@maximilianoliver25
status
ok
fetched_at
2026-08-10 15:08:05