Update README.md
Browse files
README.md
CHANGED
|
@@ -1,39 +1 @@
|
|
| 1 |
-
|
| 2 |
-
library_name: scikit-learn
|
| 3 |
-
tags:
|
| 4 |
-
- spam-detection
|
| 5 |
-
- classic-ml
|
| 6 |
-
- tfidf
|
| 7 |
-
- random-forest
|
| 8 |
-
task: text-classification
|
| 9 |
-
license: mit
|
| 10 |
-
---
|
| 11 |
-
|
| 12 |
-
# Spam Detector – RandomForest + TF-IDF (Classical ML)
|
| 13 |
-
|
| 14 |
-
**Labels:** 0 = ham, 1 = spam
|
| 15 |
-
**Training features:** TF-IDF (1k unigrams)
|
| 16 |
-
**Final model:** RandomForestClassifier
|
| 17 |
-
|
| 18 |
-
## Usage
|
| 19 |
-
|
| 20 |
-
```python
|
| 21 |
-
import joblib
|
| 22 |
-
from huggingface_hub import hf_hub_download
|
| 23 |
-
|
| 24 |
-
repo_id = "<YOUR_USERNAME>/spam-detector-rf-tfidf"
|
| 25 |
-
|
| 26 |
-
vec_path = hf_hub_download(repo_id, "vectorizer.pkl")
|
| 27 |
-
mdl_path = hf_hub_download(repo_id, "rf_model.pkl")
|
| 28 |
-
|
| 29 |
-
vectorizer = joblib.load(vec_path)
|
| 30 |
-
model = joblib.load(mdl_path)
|
| 31 |
-
|
| 32 |
-
texts = [
|
| 33 |
-
"Congratulations! You've won a free prize, click here!",
|
| 34 |
-
"Are we still on for lunch today?"
|
| 35 |
-
]
|
| 36 |
-
X = vectorizer.transform(texts)
|
| 37 |
-
proba = model.predict_proba(X)[:, 1] # probability spam
|
| 38 |
-
pred = (proba >= 0.5).astype(int)
|
| 39 |
-
print(list(zip(texts, pred, proba)))
|
|
|
|
| 1 |
+
license: apache-2.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|