타겟

Python 중급 예측 분석

Nele Verbiest Ph. D.

Senior Data Scientist @PythonPredictions

타겟 정의

Python 중급 예측 분석

타겟 타임라인 (1)

Python 중급 예측 분석

타겟 타임라인 (2)

Python 중급 예측 분석

타겟 타임라인 (3)

Python 중급 예측 분석

Python에서 타겟 정의하기

unsubscribe_2017[:5]

[90112, 65537, 24577, 8196, 73737]
baseteable.head()
   donor_id
0     65537
1     65538
2         4
3     98328
4     65564
basetable["target"] = pd.Series([1 if donor_id in unsubscribe_2017 else 0 \
for donor_id in basetable["donor_id"]])
Python 중급 예측 분석

Python에서 집계 타겟 정의하기

print(gifts.head(2))
   donor_id
0     65537
1     65538
# Target period
start_target = datetime(year = 2017, month = 1, day = 1)
end_target = datetime(year = 2018, month = 1, day = 1)

# Select target period donations gifts_target = gifts[(gifts["date"]>=start_target) & (gifts["date"]<end_target)]
# Group and sum donations by donor gifts_target_byid = gifts_target.groupby("id")["amount"].sum().reset_index()
# Derive targets and add to basetable targets = list(gifts_target_byid["id"][gifts_target_byid["amount"]>500])
basetable["target"] = pd.Series([1 if donor_id in targets else 0 for donor_id in basetable["donor_id"]])
Python 중급 예측 분석

베이스테이블

print(basetable.head())
   donor_id  target
0     65537  0
1     65538  1
2     65539  0
3     65540  1
4     65541  0
Python 중급 예측 분석

연습해 봅시다

Python 중급 예측 분석

Preparing Video For Download...