Flash Sale: Flat 70% + Addl. 25% Off on all Courses | Use Coupon DS25 in Checkout | Offer Expires In

  Enroll Now

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)))
    

No hints are availble for this assesment

Answer is not availble for this assesment


Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...