<jupyter_start><jupyter_text>Uplift Modeling Customer Email Data* In this notebook, we are going to explore [Kevin Hillstorm Email Marketing Dataset](https://blog.minethatdata.com/2008/03/minethatdata-e-mail-analytics-and-data.html), which contains outcome (Visit, Conversion and Spend) for 64,000 customers, along with other attributes such as gender, channel, historical segment, recency and zip-code type, along with Actual Marketing segments.* The dataset lays itself perfectly for Uplift Modeling and Marketing Mixture Models. Given we know treatment and control groups along with outcome and other features, we can choose customers for further targeting by using Uplift Modeling to maximize ROI. To understand individual contributing effects of these features towards Dollar amount spent, we can apply Mixture Models along with interesting interaction terms.<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns

pd.set_option('max_columns', None)
df = pd.read_csv('causal/Kevin_Hillstrom_MineThatData_E-MailAnalytics_DataMiningChallenge_2008.03.20.csv', )
df['history_segment'] = df['history_segment'].apply(lambda x: str(x)[2:])
df.head()<jupyter_output><empty_output><jupyter_text>Quick EDA* We observe that there are  2 Experimental segments,  with equal number of customers in  Womens Email Campaign, Mens Email Campaign and Control Segment. We have receny of customer, denoting number of months since last purchase (ranges from 1 to 12 months)* We also have the aggregated total dollars spent within the last 12 months on the website, and also a corresponding history segment attribute. From the distribution plot below, we observe that most of the purchases made fall within 0-100 Dollar segment and decreases with an increase in Dollar amount spent.<jupyter_code>df.segment.value_counts()
plt.figure(figsize=(16,10))

plt.subplot(2,2,1)
sns.distplot(df.recency); plt.title('Distribution Plot of Recency')

plt.subplot(2,2,2); plt.title('Count Plot of Historical Segments')
sns.countplot(df.history_segment, order=df.history_segment.value_counts().index)
plt.xticks(rotation=15)

plt.subplot(2,2,3); plt.title('Count Plot of Zipcode type')
sns.countplot(df.zip_code, order=df.zip_code.value_counts().index)

plt.subplot(2,2,4);
sns.countplot(df.newbie, order=df.newbie.value_counts().index)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08382229673093043, 'fraction_numerical': 0.020117351215423303, 'mean_word_length': 6.413043478260869, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '605950', 'license': 'MIT', 'n_tokens_mistral': 733, 'n_tokens_neox': 684, 'n_words': 251, 'path': '_jupyter/.ipynb_checkpoints/2020-05-06-Uplift Modeling Customer Email Data-checkpoint.ipynb', 'repo_name': 'AdiVarma27/adivarma27.github.io', 'size': '2386'}