Signed in as:
filler@godaddy.com
Signed in as:
filler@godaddy.com
Find articles & news from the Digital Marketing, AdTech & MarTech industries, practical casestudies, experiments, ideas & more
ChatGPT from Microsoft-backed OpenAI has dominated the Digital industry conversation, so what better place to start the blog than to test what it can do for a typical MarTech usecase that Digital Marketers & businesses have been working to crack for years.
Specifically, this is about calculating a CLV (Customer Lifetime Value) - writing a Python Notebook that can be used in i.e. your CDP (Customer Data Platform) to help with usecases, such as audience segmentation, predictive analytics, improved targeting & gaining media cost efficiencies through advertising suppression, to name a few.
It has to be said, whereas ChatGPT is known to struggle with basic arithmetic, this task came very naturally, likely because LCV calculation has been widely publised with prominent examples available online.
*Caveat: Python is not Serpentine's specialty, so tips, comments & a healthy debate are very welcome - read on & get in touch!
To cut to the chase, this is what ChatGPT came up with:
__________________________________
# Import the necessary libraries
import pandas as pd
import numpy as np
# Load the data into a pandas DataFrame
df = pd.read_csv("customer_purchases.csv")
# Calculate the average purchase value
average_purchase_value = df["purchase_amount"].mean()
# Calculate the average purchase frequency
purchase_counts = df.groupby("customer_profile")["purchase_id"].count()
average_purchase_frequency = purchase_counts.mean()
# Calculate the average customer lifespan
customer_lifespan = df.groupby("customer_profile")["date"].max() - df.groupby("customer_profile")["date"].min()
customer_lifespan = customer_lifespan / np.timedelta64(1, 'Y')
average_customer_lifespan = customer_lifespan.mean()
# Calculate the customer lifetime value
customer_lifetime_value = average_purchase_value * average_purchase_frequency * average_customer_lifespan
# Print the results
print("Customer lifetime value:", customer_lifetime_value)
This code assumes that the data is stored in a CSV file with the following columns: customer_profile, date, and purchase_amount. The average purchase value is calculated by taking the mean of the purchase_amount column. The average purchase frequency is calculated by grouping the data by the customer profile, counting the number of purchases for each customer profile, and taking the mean of the results. The average customer lifespan is calculated by subtracting the minimum and maximum purchase dates for each customer profile, converting the result to years, and taking the mean of the results. Finally, the customer lifetime value is calculated by multiplying the average purchase value, average purchase frequency, and average customer lifespan. The results are printed.
__________________________________
Not bad for a 20 second job!
Whether you could copy+paste & use it, is up for a debate, but ChatGPT covers some of the key metrics that, at the very least can serve as a useful learning material & a starting point for teams trying to develop their own CLV algorithm.
If you are planning a CDP (Customer Data Platform) implementation, or working on creating your data models & on-boarding customer profile attributes & purchase events, it also helps shaping what data you might need:
__________________________________
Main algorithm steps:
# Calculate the average purchase value
# Calculate the average purchase frequency
# Calculate the average customer lifespan
# Calculate the customer lifetime value
Baseline metrics:
# Average Purchase Value (or AOV) - calculated from averaging purchase amount
# Average Purchase Frequency - calculated from counting purchase IDs per customer profile
# Average Customer Lifespan - calculated by grouping customers with the help of min & max dates in customer profiles & calculating average years per customer
# Customer Lifetime Value - calculated by multiplying AOV by average purchase frequency & average customer lifespan
What you will need - underlying data building blocks:
# purchase_amount - in this case, assuming this is a purchase value
# customer_profile - your unique ID
# purchase_id - unique purchase ID
# date - in this case, assuming the data a purchase was made
__________________________________
...As simple as that!
If you are a Marketer, looking to understand more about AI & ML or a stakeholder, wanting to drive business value & performance through ML & AI application, ChatGPT definitely offers a topical & an exciting place to start.
If you are curious, how to plan your data collection & unification in a CDP to leverage CLV calculations & similar algorithms, contact us for more!
If you think you can do better than ChatGPT - get in touch on our Social Media - see links below ;-)