演變(evolution)的意義
在本練習中,你將使用 predictor insight graph,檢視你在前面練習加入到 basetable 的變數「donations2017min_2016」與目標值之間的關係。
為了方便你操作,建立 predictor insight graph 的方法已預先寫好。
若要在 basetable 中繪製連續變數 variable 的 predictor insight graph,可以依序執行:
- 將變數以
n_bins個箱離散化:
basetable["variable_disc"] = pd.qcut(basetable["variable"], n_bins)
- 建立 predictor insight graph 的資料表:
pig_table = create_pig_table(basetable, "target","variable_disc")
- 依據該資料表繪製 predictor insight graph:
plot_pig(pig_table,"variable_disc")
本練習屬於課程
Python 中級預測分析
練習說明
- 將演變變數
donations_2017_min_2016以 5 個箱離散化,並加入 basetable。 - 為此變數建立 predictor insight graph 的資料表。
- 繪製此變數的 predictor insight graph。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Discretize the variable in 5 bins and add to the basetable
basetable["donations_2017_min_2016_disc"] = pd.____(____["____"], ____)
# Construct the predictor insight graph table
pig_table = ____(____, "target", "____")
# Plot the predictor insight graph
plot_pig(____, "____")