Exploring your data using visualizations

Marketing Analytics: Predicting Customer Churn in Python

Mark Peterson

Director of Data Science, Infoblox

Visualizing data in Python

  • seaborn library allows you to easily create informative and attractive plots

  • Builds on top of matplotlib

Marketing Analytics: Predicting Customer Churn in Python

Visualizing the distribution of account lengths

  • Important to understand how your variables are distributed

 

import matplotlib.pyplot as plt
import seaborn as sns

sns.distplot(telco['Account_Length'])
plt.show()
Marketing Analytics: Predicting Customer Churn in Python

account_length_distribution.png

Marketing Analytics: Predicting Customer Churn in Python

Differences in account length

  • Box plot

 

sns.boxplot(x = 'Churn',
            y = 'Account_Length',
            data = telco)

plt.show()

Screenshot 2019-05-10 11.25.40.png

Marketing Analytics: Predicting Customer Churn in Python

Differences in account lengths

  • Box plot

 

sns.boxplot(x = 'Churn',
            y = 'Account_Length',
            data = telco)

plt.show()

middle_lines.png

Marketing Analytics: Predicting Customer Churn in Python

Differences in account lengths

  • Box plot

 

sns.boxplot(x = 'Churn',
            y = 'Account_Length',
            data = telco)

plt.show()

coloredboxes.png

Marketing Analytics: Predicting Customer Churn in Python

Differences in account lengths

  • Box plot

 

sns.boxplot(x = 'Churn',
            y = 'Account_Length',
            data = telco)

plt.show()

25th_percentile.png

Marketing Analytics: Predicting Customer Churn in Python

Differences in account lengths

  • Box plot

 

sns.boxplot(x = 'Churn',
            y = 'Account_Length',
            data = telco)

plt.show()

75th_percentile.png

Marketing Analytics: Predicting Customer Churn in Python

Differences in account lengths

  • Box plot

 

sns.boxplot(x = 'Churn',
            y = 'Account_Length',
            data = telco)

plt.show()

spread.png

Marketing Analytics: Predicting Customer Churn in Python

Differences in account length

  • Box plot

 

sns.boxplot(x = 'Churn',
            y = 'Account_Length',
            data = telco)

plt.show()

outliers.png

Marketing Analytics: Predicting Customer Churn in Python

Differences in account length

  • Box plot

 

sns.boxplot(x = 'Churn',
            y = 'Account_Length',
            data = telco,
            sym="")

plt.show()

Screenshot 2019-05-10 11.30.18.png

Marketing Analytics: Predicting Customer Churn in Python

Adding a third variable

sns.boxplot(x = 'Churn',
            y = 'Account_Length',
            data = telco,
            hue = 'Intl_Plan')

plt.show()

Screenshot 2019-05-10 11.41.29.png

Marketing Analytics: Predicting Customer Churn in Python

Let's make some plots!

Marketing Analytics: Predicting Customer Churn in Python

Preparing Video For Download...