Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Putting All Together | Identifying Spam Emails
Identifying Spam Emails

book
Putting All Together

Tâche

Swipe to start coding

  1. Import the accuracy_score() function.
  2. Predict labels using the logistic regression classifier with the appropriate method.
  3. Print out the accuracy using the appropriate function.

Solution

# Import the accuracy_score() function
from sklearn.metrics import accuracy_score

test_document_term_matrix = count_vectorizer.transform(X_test)
test_document_term_matrix = test_document_term_matrix.toarray()

# Predict labels using the logistic regression classifier
pred = logistic_regression.predict(test_document_term_matrix)

# Print out the accuracy
print('Accuracy: ', accuracy_score(y_test, pred) * 100)

Congratulations on completing the course on classifying spam emails! The ability to effectively identify and filter spam is a valuable skill in today's digital age. I hope you have gained a deeper understanding of the techniques and algorithms used to combat spam, and that you can apply what you have learned to improve the efficiency and accuracy of your own email systems. Keep up the good work, and all the best for your future endeavors!

Mark tasks as Completed
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 1. Chapitre 11
AVAILABLE TO ULTIMATE ONLY
some-alt