Download inference.py from ncfad/spam_classifier: direct link, hf CLI and curl.
- Browser
- Download file 220 Bytes
-
https://huggingface.co/ncfad/spam_classifier/resolve/main/inference.py
- Command line
-
hf download hf://ncfad/spam_classifier/inference.py
-
curl -L -o inference.py https://huggingface.co/ncfad/spam_classifier/resolve/main/inference.py
220 Bytes
| import joblib | |
| model = joblib.load("model.pkl") | |
| tfidf = joblib.load("vectorizer.pkl") | |
| def predict(text): | |
| X = tfidf.transform([text]) | |
| pred = model.predict(X)[0] | |
| return "spam" if pred == 1 else "ham" | |