Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,32 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Spam Detection — English (Naive Bayes)
|
| 2 |
+
|
| 3 |
+
A lightweight spam/ham text classifier for English messages, built with a
|
| 4 |
+
custom preprocessing pipeline (tokenization, stopword removal, lemmatization)
|
| 5 |
+
and TF-IDF features feeding into a Multinomial Naive Bayes classifier.
|
| 6 |
+
|
| 7 |
+
## Model Details
|
| 8 |
+
- **Architecture:** TF-IDF + Multinomial Naive Bayes (scikit-learn Pipeline)
|
| 9 |
+
- **Preprocessing:** Custom transformer — hashtag/punctuation removal,
|
| 10 |
+
tokenization (NLTK), stopword removal, lemmatization (WordNet)
|
| 11 |
+
- **Hyperparameters:** Tuned via GridSearchCV (alpha smoothing)
|
| 12 |
+
- **Accuracy:** 99.4% on held-out test set
|
| 13 |
+
|
| 14 |
+
## Intended Use
|
| 15 |
+
Binary spam classification for English text messages/emails. Part of a
|
| 16 |
+
multilingual spam detection system that automatically routes text to a
|
| 17 |
+
language-specific model (English or Arabic) based on detected language.
|
| 18 |
+
|
| 19 |
+
## How to Use
|
| 20 |
+
\```python
|
| 21 |
+
import joblib
|
| 22 |
+
|
| 23 |
+
model = joblib.load("spam_eng_nb.joblib")
|
| 24 |
+
prediction = model.predict(["Congratulations! You've won a free prize, click here now"])
|
| 25 |
+
print(prediction) # 1 = spam, 0 = ham
|
| 26 |
+
\```
|
| 27 |
+
|
| 28 |
+
## Limitations
|
| 29 |
+
- Trained on a specific dataset distribution; may not generalize well to
|
| 30 |
+
domains very different from training data (e.g. highly technical or
|
| 31 |
+
slang-heavy text)
|
| 32 |
+
- Naive Bayes assumes word independence — does not capture context or word order
|