DarkNeuron-AI commited on
Commit
6398802
·
verified ·
1 Parent(s): 68a75c5

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +18 -12
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
- # 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
 
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