模型效能
你現在要用前一個單元建立的模型來評估測試資料。
用全新、未見過的資料來評估很重要,因為這能驗證模型對從未遇過的資料是否也能做出正確的預估。
所有需要的模組都已匯入,資料分別以 X_train、y_train 及 X_test、y_test 提供。
本練習屬於課程
使用 Python 分析 IoT 資料
練習說明
- 建立一個
LogisticRegression模型。 - 使用
X_train和y_train來擬合模型。 - 使用
X_train和y_train來評分模型。 - 使用
X_test和y_test來評分模型。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Create LogisticRegression model
logreg = ____()
# Fit the model
logreg.____(____, ____)
# Score the model
print(logreg.____(____, ____))
print(____)