Advertisement
gk231192

Module 9.2 Naive Bayes

Jul 3rd, 2025
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. # 3. Naive Bayes
  2. # What it does: Uses probability based on Bayes' Theorem. Assumes all features are independent.
  3. # Use Case: Spam filters, sentiment analysis.
  4.  
  5. from sklearn.naive_bayes import GaussianNB
  6. nb = GaussianNB()
  7. nb.fit(X_train_scaled, y_train)
  8. y_pred = nb.predict(X_test_scaled)
  9. print("Naive Bayes Confusion Matrix:\n", confusion_matrix(y_test, y_pred))
  10. print("\nNaive Bayes Classification Report:\n", classification_report(y_test, y_pred))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement