Mini Project)ショッピングモール受注データによるデータ分析−(4)データに基づく意思決定−プッシュ通知時間
4.データに基づく決定-プッシュ通知時間
1.ライブラリインポートと棒グラフ描画機能の定義
import numpy as np
import pandas as pd
# seaborn
import seaborn as sns
COLORS = sns.color_palette()
%matplotlib inline
def plot_bar(df, xlabel, ylabel, title, figsize=(20, 10), color=COLORS[-1], rotation=45):
plot = df.plot(kind='bar', color=color, figsize=figsize)
plot.set_xlabel(xlabel, fontsize=10)
plot.set_ylabel(ylabel, fontsize=10)
plot.set_title(title, fontsize=12)
plot.set_xticklabels(labels=df.index, rotation=rotation)
データをロードし、InvoiceDateを再フォーマットします.dtypes = {
'UnitPrice': np.float32,
'CustomerID': np.int32,
'Quantity': np.int32
}
retail = pd.read_csv('../Data/OnlineRetailClean.csv', dtype=dtypes)
retail['InvoiceDate'] = pd.to_datetime(retail['InvoiceDate'], infer_datetime_format=True)
retail.head()
日付のフォーマットに関連する正式なライブラリリンク 書式設定前
書式設定後
2.クーポン発行等のプッシュタイミングを考える
現実的に最も注文が多い場合にプッシュするのが最も直感的な判断といえる.
主に時間(時間,分)に関わるため,InvoiceDateが最も重要な特徴といえる.
# 시간 그룹 별 고객 수를 카운트한다.
order_by_hour = retail.set_index('InvoiceDate').groupby(lambda date: date.hour).count()['CustomerID']
order_by_hour
グラフィックの描画plot_bar(order_by_hour, 'Hour', '# Orders', 'Order by Hour')
12時代の売上高は圧倒的に高かった.
各購入イベントの時間を30分短縮する関数を定義します.
def half_an_hour(date):
minute = ':00'
if date.minute > 30:
minute = ':30'
hour = str(date.hour)
if date.hour < 10:
hour = '0' + hour
return hour + minute
30分ごとの顧客数の結果order_by_hour_half = retail.set_index('InvoiceDate').groupby(half_an_hour).count()['CustomerID']
order_by_hour_half
plot_bar(order_by_hour_half,'Half an hour', '# Orders', 'Order by half an hour')
30分単位でカットした結果、12時と12時30分、つまり12時と13時に購入したお客様が一番多かったです.
order_by_hour_half / order_by_hour_half.sum() * 100
全体の割合で見ると、12時代が全体の18%を占め、1時代が16%前後を占めている.
個人差押え通知時間を考える
order_count_by_hour = retail.set_index('InvoiceDate').groupby(['CustomerID', lambda date: date.hour]).count()['StockCode']
order_count_by_hour
お客様の購入時間帯と購入品の購入回数によって.
ユーザーあたりの最大注文時間の計算
idx = order_count_by_hour.groupby('CustomerID').idxmax()
時間別索引
# 시간으로 indexing
result = order_count_by_hour.loc[idx]
result
最終的に1時間あたりの購入者IDリストを取得
result.reset_index().groupby('level_1').groups
これにより、各時間帯の顧客リストの顧客にクーポンなどを送ることで、顧客の購入を引き付けることができるかもしれません.
第4話終了
Reference
この問題について(Mini Project)ショッピングモール受注データによるデータ分析−(4)データに基づく意思決定−プッシュ通知時間), 我々は、より多くの情報をここで見つけました https://velog.io/@kmnkit/Mini-Project쇼핑몰-주문-데이터를-활용한-데이터분석-4데이터-기반-의사결정-Push-Notification-Timeテキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol