Calculating average incidences
The most important column in the predictor insight graph table is the target incidence column. This column shows the average target value for each group.
Latihan ini adalah bagian dari kursus
Introduction to Predictive Analytics in Python
Petunjuk latihan
- Create a DataFrame
basetable_incomethat only contains the variablestargetandincome. - Group this DataFrame by
income. - Calculate the average target incidence for each group in
income.
Latihan interaktif praktis
Cobalah latihan ini dengan menyelesaikan kode contoh berikut.
# Select the income and target columns
basetable_income = basetable[["____","____"]]
# Group basetable_income by income
groups = basetable_income.____("____")
# Calculate the target incidence and print the result
incidence = groups["____"].agg(Incidence = '____').reset_index()
print(incidence)