開始使用免費開始

重用模型參數

在模型驗證中,能夠重現模型效能非常關鍵。當你要與同事分享模型、在新資料上重用模型,或在像是 Stack Overflow 這樣的網站上發問時,重現同樣重要。你可能會在這類網站請教其他程式設計者關於模型錯誤、輸出或效能的問題。最好的方式是透過重用模型參數來重現你的工作。

在這個練習中,你會用各種方法回顧模型中使用過的參數。

本練習屬於課程

Python 的模型驗證

檢視課程

練習說明

  • 直接列印模型,輸出模型 rfc 的特性。
  • 只列印模型的 random state。
  • 列印模型參數的字典。

動手互動練習

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

rfc = RandomForestClassifier(n_estimators=50, max_depth=6, random_state=1111)

# Print the classification model
____(____)

# Print the classification model's random state parameter
print('The random state is: {}'.format(rfc.____))

# Print all parameters
print('Printing the parameters dictionary: {}'.format(rfc.____()))
編輯並執行程式碼