Update README.md
Browse files
README.md
CHANGED
|
@@ -40,31 +40,37 @@ It classifies emails as **Spam (1)** or **Ham (0)** with high accuracy and fast
|
|
| 40 |
|
| 41 |
## 💡 How to Use
|
| 42 |
```python
|
|
|
|
| 43 |
import joblib
|
|
|
|
| 44 |
import re
|
| 45 |
-
import string
|
| 46 |
|
| 47 |
-
#
|
| 48 |
-
|
| 49 |
-
vectorizer = joblib.load(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 59 |
-
|
|
|
|
| 60 |
|
| 61 |
-
#
|
| 62 |
-
|
| 63 |
-
email_vec = vectorizer.transform([clean_email])
|
| 64 |
|
| 65 |
# Predict
|
| 66 |
-
|
| 67 |
-
|
|
|
|
| 68 |
```
|
| 69 |
|
| 70 |
# Developed With ❤️ By DarkNeuronAI
|
|
|
|
| 40 |
|
| 41 |
## 💡 How to Use
|
| 42 |
```python
|
| 43 |
+
from huggingface_hub import hf_hub_download
|
| 44 |
import joblib
|
| 45 |
+
import string
|
| 46 |
import re
|
|
|
|
| 47 |
|
| 48 |
+
# Download and load the vectorizer
|
| 49 |
+
vectorizer_path = hf_hub_download("DarkNeuron-AI/darkneuron-spamdex-v1", "spam_detection_vectorizer.pkl")
|
| 50 |
+
vectorizer = joblib.load(vectorizer_path)
|
| 51 |
+
|
| 52 |
+
# Download and load the trained model
|
| 53 |
+
model_path = hf_hub_download("DarkNeuron-AI/darkneuron-spamdex-v1", "spam_detection_model.pkl")
|
| 54 |
+
model = joblib.load(model_path)
|
| 55 |
|
| 56 |
# Text cleaning function
|
| 57 |
def clean_text(text):
|
| 58 |
text = text.lower() # lowercase
|
| 59 |
text = re.sub(r'\d+', '', text) # remove digits
|
| 60 |
text = text.translate(str.maketrans('', '', string.punctuation)) # remove punctuation
|
| 61 |
+
return text.strip() # remove extra spaces
|
| 62 |
|
| 63 |
+
# Example usage
|
| 64 |
+
email_text = "Congratulations! You are the topper!"
|
| 65 |
+
cleaned_email = clean_text(email_text)
|
| 66 |
|
| 67 |
+
# ✅ Wrap text in a list for vectorizer
|
| 68 |
+
email_vector = vectorizer.transform([cleaned_email])
|
|
|
|
| 69 |
|
| 70 |
# Predict
|
| 71 |
+
prediction = model.predict(email_vector)
|
| 72 |
+
|
| 73 |
+
print("Prediction:", "🚨 Spam" if prediction[0] == 1 else "✅ Not Spam")
|
| 74 |
```
|
| 75 |
|
| 76 |
# Developed With ❤️ By DarkNeuronAI
|