開始使用免費開始

建立累積增益曲線

累積增益曲線是一種用來評估模型效能的曲線。它會根據你的模型判定為最有可能屬於目標的族群比例,顯示在考慮該比例的人口時,實際可觸及的目標百分比。

要建立這條曲線,你可以使用 scikitplot 模組中的 .plot_cumulative_gain() 方法,並搭配 matplotlib.pyplot 模組。和其他模型評估指標或曲線一樣,你需要同時準備實際的目標值與模型的預測值,才能繪製累積增益曲線。

本練習屬於課程

Python 預測分析入門

檢視課程

練習說明

  • 匯入 matplotlib.pyplot 模組。
  • 匯入 scikitplot 模組。
  • 已知模型的輸出在 predictions_test,而實際目標值在 targets_test,請繪製累積增益曲線。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Import the matplotlib.pyplot module 
import ____.____ as plt

# Import the scikitplot module
import ____ as skplt

# Plot the cumulative gains graph
skplt.metrics.____(targets_test, ____)
plt.show()
編輯並執行程式碼