Online shopping decisions rely on how consumers engage with online store content. You work for a new startup company that has just launched a new online shopping website. The marketing team asks you, a new data scientist, to review a dataset of online shoppers' purchasing intentions gathered over the last year. Specifically, the team wants you to generate some insights into customer browsing behaviors in November and December, the busiest months for shoppers. You have decided to identify two groups of customers: those with a low purchase rate and returning customers. After identifying these groups, you want to determine the probability that any of these customers will make a purchase in a new marketing campaign to help gauge potential success for next year's sales.
Data description:
You are given an online_shopping_session_data.csv
that contains several columns about each shopping session. Each shopping session corresponded to a single user.
Column | Description |
---|---|
SessionID | unique session ID |
Administrative | number of pages visited related to the customer account |
Administrative_Duration | total amount of time spent (in seconds) on administrative pages |
Informational | number of pages visited related to the website and the company |
Informational_Duration | total amount of time spent (in seconds) on informational pages |
ProductRelated | number of pages visited related to available products |
ProductRelated_Duration | total amount of time spent (in seconds) on product-related pages |
BounceRates | average bounce rate of pages visited by the customer |
ExitRates | average exit rate of pages visited by the customer |
PageValues | average page value of pages visited by the customer |
SpecialDay | closeness of the site visiting time to a specific special day |
Weekend | indicator whether the session is on a weekend |
Month | month of the session date |
CustomerType | customer type |
Purchase | class label whether the customer make a purchase |
# Import required libraries
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy import stats
# Load and view your data
shopping_data = pd.read_csv("online_shopping_session_data.csv")
shopping_data.head()
# Start your code here!
# Use as many cells as you like
purchase_nov_dec = shopping_data[shopping_data['Month'].isin(['Nov', 'Dec'])]
rates = purchase_nov_dec.groupby(['CustomerType'])['Purchase']\
.value_counts(normalize=True)
purchase_rates = {customer: value for (customer, purchase), value in rates.items() if purchase == 1}
matrix_corr = purchase_nov_dec[['Administrative_Duration', 'Informational_Duration', 'ProductRelated_Duration']].corr()
pairs = []
for i, col1 in enumerate(matrix_corr.columns):
for j, col2 in enumerate(matrix_corr.columns):
if i < j: # Evitar duplicados y la diagonal
corr = matrix_corr.loc[col1, col2].round(3)
pairs.append({
"pair": (col1, col2),
"correlation": corr
})
top_correlation = max(pairs, key=lambda x: abs(x["correlation"]))
new_rate = purchase_rates['Returning_Customer'] * 1.15
prob_at_least_100_sales = 1 - stats.binom.cdf(100, 500, new_rate)