Skip to content

Statistics Mini Project (Analyze a Marketing Campaign)

Goal

Given a marketing campaign dataset, you will:

  • compute descriptive statistics
  • compare two segments (A vs B)
  • build confidence intervals
  • produce a short written conclusion

Example dataset columns

  • user_iduser_id
  • variantvariant (A/B)
  • convertedconverted (0/1)
  • revenuerevenue
  • countrycountry

Step 1: Load

Load campaign data
import pandas as pd
 
df = pd.read_csv("data/campaign.csv")
print(df.head())
Load campaign data
import pandas as pd
 
df = pd.read_csv("data/campaign.csv")
print(df.head())

Step 2: Quick summary

Group summary
summary = (
    df.groupby("variant")
      .agg(
          users=("user_id", "nunique"),
          conversion_rate=("converted", "mean"),
          avg_revenue=("revenue", "mean"),
          median_revenue=("revenue", "median"),
      )
)
print(summary)
Group summary
summary = (
    df.groupby("variant")
      .agg(
          users=("user_id", "nunique"),
          conversion_rate=("converted", "mean"),
          avg_revenue=("revenue", "mean"),
          median_revenue=("revenue", "median"),
      )
)
print(summary)

Step 3: Visualize

Use either Matplotlib/Seaborn/Plotly:

  • conversion bar chart
  • revenue distribution comparison

Step 4: Test conversion difference (approx)

Use the “A/B Testing Basics” approach.

Step 5: Deliverable

Write a short conclusion:

  • Does variant B improve conversion?
  • Is the result practically meaningful?
  • Any data quality concerns?

The project pipeline

diagram Marketing campaign analysis pipeline mermaid
Every step from this phase gets used once: load, describe, estimate, test, and conclude.

🧪 Try It Yourself

Exercise 1 – Descriptive summary by variant

Exercise 2 – CI on the conversion-rate difference

Exercise 3 – Writing a defensible conclusion

Next

This wraps up the Statistics phase. Carry these tools — descriptive stats, confidence intervals, and hypothesis testing — into modeling and machine learning, where the same ideas reappear as regression diagnostics and model evaluation metrics.

If this helped you, consider buying me a coffee ☕

Buy me a coffee

Was this page helpful?

Let us know how we did