Login using Social Account
     Continue with GoogleLogin using your credentials
Finally, we will calculate the precision and recall for the model that we created in the previous step.
First, we will import precision_score
and recall_score
from Scikit-learn:
from sklearn.metrics import precision_score, << your code goes here >>
Put the test set through the pipeline we created:
X_test_transformed = << your code goes here >>.transform(X_test)
Fit our model on the test set:
log_clf = LogisticRegression(solver="lbfgs", random_state=42)
log_clf.fit(X_train_transformed, y_train)
Make our predictions using predict on the transformed test dataset:
y_pred = log_clf.<< your code goes here >>(X_test_transformed)
Finally, we will calculate and print the Precision and Recall scores of our model:
print("Precision: {:.2f}%".format(100 * precision_score(y_test, y_pred)))
print("Recall: {:.2f}%".format(100 * recall_score(y_test, y_pred)))
Want to create exercises like this yourself? Click here.
Note - Having trouble with the assessment engine? Follow the steps listed here
Loading comments...