训练分类器
上一练习中创建的数据框 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.____.____)