|
|
--- |
|
|
license: mit |
|
|
language: |
|
|
- en |
|
|
metrics: |
|
|
- accuracy |
|
|
- precision |
|
|
- recall |
|
|
- f1 |
|
|
pipeline_tag: text-classification |
|
|
library_name: sklearn |
|
|
tags: |
|
|
- Email Spam Detection |
|
|
- Naive Bayes |
|
|
- TF-IDF |
|
|
--- |
|
|
|
|
|
# π§ SpamDex - Spam Detection Model (v1.0) |
|
|
|
|
|
A lightweight **Naive Bayes + TF-IDF** based spam detection model developed by **DarkNeuronAI**. |
|
|
It classifies emails as **Spam (1)** or **Ham (0)** with high accuracy and fast performance β ideal for simple text classification tasks. |
|
|
|
|
|
--- |
|
|
|
|
|
## π Features |
|
|
- Fast and efficient β works on low-end systems |
|
|
- Trained with real-world email dataset |
|
|
- Perfect for **text classification** and **spam filtering** projects |
|
|
- Easy to use and integrate |
|
|
|
|
|
--- |
|
|
|
|
|
## π Model Overview |
|
|
- **Algorithm:** Naive Bayes (MultinomialNB) |
|
|
- **Vectorization:** TF-IDF (Term Frequency - Inverse Document Frequency) |
|
|
- **Goal:** Classify email/text messages as Spam or Ham |
|
|
- **Performance:** High accuracy on real-world datasets |
|
|
|
|
|
--- |
|
|
|
|
|
## π§© Files Included |
|
|
- `spam_detection_model.pkl` β Trained Naive Bayes model |
|
|
- `spam_detection_vectorizer.pkl` β TF-IDF vectorizer for text preprocessing |
|
|
- `example_usage.py` β Example code to use the model |
|
|
- `requirements.txt` β Dependencies list |
|
|
|
|
|
--- |
|
|
|
|
|
## π·οΈ Prediction Labels(Binary) |
|
|
- **0:** Represent Ham(Not Spam) Prediction |
|
|
- **1:** Represent Spam Prediction |
|
|
|
|
|
## π‘ How to Use(Example Code) |
|
|
```python |
|
|
from huggingface_hub import hf_hub_download |
|
|
import joblib |
|
|
import string |
|
|
import re |
|
|
|
|
|
# Download and load the vectorizer |
|
|
vectorizer_path = hf_hub_download("DarkNeuron-AI/darkneuron-spamdex-v1", "spam_detection_vectorizer.pkl") |
|
|
vectorizer = joblib.load(vectorizer_path) |
|
|
|
|
|
# Download and load the trained model |
|
|
model_path = hf_hub_download("DarkNeuron-AI/darkneuron-spamdex-v1", "spam_detection_model.pkl") |
|
|
model = joblib.load(model_path) |
|
|
|
|
|
# Text cleaning function |
|
|
def clean_text(text): |
|
|
text = text.lower() # lowercase |
|
|
text = re.sub(r'\d+', '', text) # remove digits |
|
|
text = text.translate(str.maketrans('', '', string.punctuation)) # remove punctuation |
|
|
return text.strip() # remove extra spaces |
|
|
|
|
|
# Example usage |
|
|
email_text = "Congratulations! You are the topper!" |
|
|
cleaned_email = clean_text(email_text) |
|
|
|
|
|
# Wrap text in a list for vectorizer |
|
|
email_vector = vectorizer.transform([cleaned_email]) |
|
|
|
|
|
# Predict |
|
|
prediction = model.predict(email_vector) |
|
|
|
|
|
print("Prediction:", "π¨ Spam" if prediction[0] == 1 else "β
Not Spam") |
|
|
``` |
|
|
|
|
|
# Developed With β€οΈ By DarkNeuronAI |