Skip to Content
Mastering Marketing Data Science
book

Mastering Marketing Data Science

by Iain Brown
April 2024
Beginner to intermediate
432 pages
12h 45m
English
Wiley
Content preview from Mastering Marketing Data Science

EXERCISE 10.1: ANALYZING A SIMPLE A/B TEST

Objective: To demonstrate the basic principles of experimental design using an A/B test scenario in email marketing.

Tasks:

You are provided with data from an email marketing campaign where two different subject lines were tested to see which one yields a higher open rate. Your task is to analyze the data to determine which subject line performed better.

  1. Statistical Test: Perform a t-test to see if the difference in open rates between the two groups is statistically significant.
  2. Interpret Results: Based on the p-value from the t-test, conclude which subject line performed better.

Steps:

  1. Import Libraries:
    1. import scipy.stats as stats
    2. import pandas as pd

    We import two libraries: scipy.stats for statistical tests and pandas for handling data in a structured form (DataFrames).

  2. Load the Data:
    3. email_marketing_data = pd.read_csv(‘/data/Email_Marketing_AB_Test_Data.csv’)

    We load the data into a pandas DataFrame. This data simulates the open rates of emails for two different subject lines (Group A and Group B).

  3. Separate the Data into Two Groups:
    4. group_A = email_marketing_data[email_marketing_data[‘Group’] == ‘A’][‘OpenRate’]
    5. group_B = email_marketing_data[email_marketing_data[‘Group’] == ‘B’][‘OpenRate’]

    Here, we filter the DataFrame to create two separate series: one for each group. group_A contains the open rates for subject line A, and group_B for subject line B.

  4. Perform a t-Test:
    6. t_stat, p_value = stats.ttest_ind(group_A, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Data Science for Business

Data Science for Business

Foster Provost, Tom Fawcett
Data Science for Marketing Analytics - Second Edition

Data Science for Marketing Analytics - Second Edition

Mirza Rahim Baig, Gururajan Govindan, Vishwesh Ravi Shrimali

Publisher Resources

ISBN: 9781394258710Purchase Link