訓練分類器
你在前一個練習建立的資料框 df_trainset 已經可用。現在要用它來訓練一個邏輯斯回歸分類器。
本練習屬於課程
Python Spark SQL 入門
練習說明
- 匯入邏輯斯回歸分類器。
- 具現化分類器。將最大迭代次數設為 100、正規化參數設為 0.4、Elastic Net 參數設為 0.0。
- 在訓練集上訓練分類器。
- 列印訓練迭代次數。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Import the logistic regression classifier
from ____ import ____
# Instantiate logistic setting elasticnet to 0.0
logistic = ____(maxIter=100, regParam=0.4, ____=0.0)
# Train the logistic classifer on the trainset
df_fitted = ____.____(____)
# Print the number of training iterations
print("Training iterations: ", df_fitted.____.____)