Editing
Ai Marketing
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== <span style="color: #FFFFFF;">Applying</span> == '''Customer LTV and churn prediction pipeline:''' <syntaxhighlight lang="python"> import pandas as pd import numpy as np from sklearn.ensemble import GradientBoostingClassifier, GradientBoostingRegressor from sklearn.model_selection import train_test_split from sklearn.metrics import roc_auc_score, mean_absolute_percentage_error import shap # Load customer transaction data df = pd.read_csv("customer_transactions.csv") df['order_date'] = pd.to_datetime(df['order_date']) # RFM features (Recency, Frequency, Monetary) cutoff_date = df['order_date'].max() rfm = df.groupby('customer_id').agg( recency=('order_date', lambda x: (cutoff_date - x.max()).days), frequency=('order_id', 'nunique'), monetary=('order_value', 'sum'), avg_order_value=('order_value', 'mean'), days_since_first=('order_date', lambda x: (cutoff_date - x.min()).days), order_gap_std=('order_date', lambda x: x.sort_values().diff().dt.days.std()), ).reset_index() # Churn model (target: no purchase in last 90 days) rfm['churned'] = (rfm['recency'] > 90).astype(int) features = ['recency', 'frequency', 'monetary', 'avg_order_value', 'days_since_first', 'order_gap_std'] X, y = rfm[features].fillna(0), rfm['churned'] X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, stratify=y) churn_model = GradientBoostingClassifier(n_estimators=200, max_depth=4) churn_model.fit(X_train, y_train) print(f"Churn AUC: {roc_auc_score(y_test, churn_model.predict_proba(X_test)[:,1]):.3f}") # LTV model (target: next 12 months revenue) rfm_ltv = rfm[rfm['churned'] == 0].copy() # Only active customers X_ltv = rfm_ltv[features].fillna(0) y_ltv = rfm_ltv['next_12m_revenue'] # Requires additional data preparation ltv_model = GradientBoostingRegressor(n_estimators=200).fit(X_ltv, y_ltv) # SHAP explanations for campaign targeting decisions explainer = shap.TreeExplainer(churn_model) shap_values = explainer.shap_values(X_test) shap.summary_plot(shap_values, X_test, feature_names=features) </syntaxhighlight> ; Marketing AI tool landscape : '''Ad platform AI''' β Google Performance Max, Meta Advantage+, Amazon DSP : '''MMM''' β Meta Robyn, Google Meridian (open source), Analytic Partners : '''Attribution''' β Northbeam, Triple Whale, Rockerbox (post-iOS 14) : '''Email personalization''' β Klaviyo AI, Braze, Iterable predictive sending : '''Audience platforms''' β LiveRamp, The Trade Desk AI, Salesforce Marketing Cloud : '''Experimentation''' β Optimizely, VWO, LaunchDarkly (feature flags + stats) </div> <div style="background-color: #8B4500; color: #FFFFFF; padding: 20px; border-radius: 8px; margin-bottom: 15px;">
Summary:
Please note that all contributions to BloomWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
BloomWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information