Spam Detection — English (Naive Bayes)
A lightweight spam/ham text classifier for English messages, built with a custom preprocessing pipeline (tokenization, stopword removal, lemmatization) and TF-IDF features feeding into a Multinomial Naive Bayes classifier.
Model Details
- Architecture: TF-IDF + Multinomial Naive Bayes (scikit-learn Pipeline)
- Preprocessing: Custom transformer — hashtag/punctuation removal, tokenization (NLTK), stopword removal, lemmatization (WordNet)
- Hyperparameters: Tuned via GridSearchCV (alpha smoothing)
- Accuracy: 99.4% on held-out test set
Intended Use
Binary spam classification for English text messages/emails. Part of a multilingual spam detection system that automatically routes text to a language-specific model (English or Arabic) based on detected language.
How to Use
import joblib
model = joblib.load("spam_eng_nb.joblib")
prediction = model.predict(["Congratulations! You've won a free prize, click here now"])
print(prediction) # 1 = spam, 0 = ham
Evaluation results
- Accuracy on English Spam Datasetself-reported0.994