Train the classifier
The dataframe df_trainset
you created in the previous exercise is available. You're now going to use it to train a Logistic Regression Classifier.
This exercise is part of the course
Introduction to Spark SQL in Python
Exercise instructions
- Import the Logistic Regression Classifier.
- Instantiate the classifier. Set maximum iterations to 100, the regularization parameter to 0.4, and the elastic net parameter to 0.0.
- Train the classifier on the trainset.
- Print the number of training iterations.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# 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.____.____)