Update README.md
Browse files
README.md
CHANGED
|
@@ -13,4 +13,58 @@ tags:
|
|
| 13 |
- Email Spam Detection
|
| 14 |
- Naive Bayes
|
| 15 |
- TF-IDF
|
| 16 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
- Email Spam Detection
|
| 14 |
- Naive Bayes
|
| 15 |
- TF-IDF
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# 🧠 DarkNeuronAI - Spam Detection v1.0
|
| 19 |
+
|
| 20 |
+
A lightweight **Naive Bayes + TF-IDF** based spam detection model developed by **DarkNeuronAI**.
|
| 21 |
+
It classifies emails as **Spam (1)** or **Ham (0)** with high accuracy and fast performance — ideal for simple text classification tasks.
|
| 22 |
+
|
| 23 |
+
---
|
| 24 |
+
|
| 25 |
+
## 🚀 Model Overview
|
| 26 |
+
- **Algorithm:** Naive Bayes (MultinomialNB)
|
| 27 |
+
- **Vectorization:** TF-IDF (Term Frequency - Inverse Document Frequency)
|
| 28 |
+
- **Goal:** Classify email/text messages as Spam or Ham
|
| 29 |
+
- **Performance:** High accuracy on real-world datasets
|
| 30 |
+
|
| 31 |
+
---
|
| 32 |
+
|
| 33 |
+
## 🧩 Files Included
|
| 34 |
+
- `spam_detection_model.pkl` → Trained Naive Bayes model
|
| 35 |
+
- `spam_detection_vectorizer.pkl` → TF-IDF vectorizer for text preprocessing
|
| 36 |
+
- `example_usage.py` → Example code to use the model
|
| 37 |
+
- `requirements.txt` → Dependencies list
|
| 38 |
+
|
| 39 |
+
---
|
| 40 |
+
|
| 41 |
+
## 💡 How to Use
|
| 42 |
+
```python
|
| 43 |
+
import joblib
|
| 44 |
+
import re
|
| 45 |
+
import string
|
| 46 |
+
|
| 47 |
+
# Load model and vectorizer
|
| 48 |
+
model = joblib.load("spam_detection_model.pkl")
|
| 49 |
+
vectorizer = joblib.load("spam_detection_vectorizer.pkl")
|
| 50 |
+
|
| 51 |
+
# Text cleaning function
|
| 52 |
+
def clean_text(text):
|
| 53 |
+
text = text.lower() # lowercase
|
| 54 |
+
text = re.sub(r'\d+', '', text) # remove digits
|
| 55 |
+
text = text.translate(str.maketrans('', '', string.punctuation)) # remove punctuation
|
| 56 |
+
return text.strip() # remove spaces
|
| 57 |
+
|
| 58 |
+
# Example email
|
| 59 |
+
email = "Congratulations! You have won $1000. Click here to claim now!"
|
| 60 |
+
|
| 61 |
+
# Clean and transform
|
| 62 |
+
clean_email = clean_text(email)
|
| 63 |
+
email_vec = vectorizer.transform([clean_email])
|
| 64 |
+
|
| 65 |
+
# Predict
|
| 66 |
+
result = model.predict(email_vec)
|
| 67 |
+
print("Spam" if result[0] == 1 else "Ham")
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
# Developed With ❤️ By DarkNeuronAI
|