加入可預測變數

Python 中級預測分析

Nele Verbiest

Senior Data Scientist @PythonPredictions

可預測變數

  • 人口統計:
    • 年齡
    • 性別
    • 居住地
  • 消費行為
  • 收視行為
  • 產品使用
  • 上網行為
  • 付款資訊
Python 中級預測分析

符合時間軸的可預測變數(1)

Python 中級預測分析

符合時間軸的可預測變數(2)

Python 中級預測分析

加入存續時間

# Reference date
reference_date = datetime.date(2018,4,1)

# Add lifetime to the basetable basetable["lifetime"] = reference_date - basetable["member_since"] print(basetable.head())
donor_id member_since lifetime
1        2015-02-03   1153
2        2016-01-30   729
3        2016-02-23   768
Python 中級預測分析

加入偏好聯絡管道(1)

donor_id start_valid_date end_valid_date  contact_channel
1        2014-02-03       2016-03-04      "phone"
1        2016-03-04       2016-05-08      "e-mail"
2        2016-02-23       2026-02-23      "e-mail"
reference_date = datetime.date(2018,4,1)

# Select lines compliant with reference data contact_channel_reference_date = living_places[ (contact_channel["start_valid_date"]<=reference_date) & (living_places["end_valid_date"]>reference_date)]
Python 中級預測分析

加入偏好聯絡管道(2)

# Add contact channel place to the basetable
basetable = 
    pd.merge(
     basetable, 
     living_places_reference_date[["donor_ID","contact_channel"]],
     on="donor_ID"
    )
print(basetable.head())
donor_id contact_channel
1        "phone"
2        "phone"
3        "e-mail"
Python 中級預測分析

一起來練習吧!

Python 中級預測分析

Preparing Video For Download...