Project - Building Spam Classifier

You are currently auditing this course.
27 / 27

Spam Classifier - Calculate the Precision and Recall for the model

Finally, we will calculate the precision and recall for the model that we created in the previous step.

INSTRUCTIONS
  • 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)))
    
Get Hint See Answer

Loading comments...