Instructions to use DarkNeuronAI/darkneuron-spamdex-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use DarkNeuronAI/darkneuron-spamdex-v1 with Scikit-learn:
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("DarkNeuronAI/darkneuron-spamdex-v1", "sklearn_model.joblib") ) # only load pickle files from sources you trust # read more about it here https://skops.readthedocs.io/en/stable/persistence.html - Notebooks
- Google Colab
- Kaggle
| import joblib | |
| import re | |
| import string | |
| # 🧹 Reuse the same clean_text function | |
| def clean_text(text): | |
| text = text.lower() | |
| text = re.sub(r'\d+', '', text) # remove numbers | |
| text = text.translate(str.maketrans('', '', string.punctuation)) # remove punctuation | |
| text = text.strip() | |
| return text | |
| # 💾 Load the saved model and vectorizer | |
| model = joblib.load("spam_detection_model.pkl") | |
| vectorizer = joblib.load("spam_detection_vectorizer.pkl") | |
| # 💬 Function to predict a new message | |
| def predict_message(msg): | |
| msg_clean = clean_text(msg) | |
| msg_vec = vectorizer.transform([msg_clean]) | |
| pred = model.predict(msg_vec)[0] | |
| return "🚨 Spam" if pred == 1 else "✅ Not Spam" | |
| # 🧪 Test with some examples | |
| print(predict_message("Congratulations! You have won a car")) | |
| print(predict_message("Hey, click here to claim your reward")) | |
| print(predict_message("Exclusive offer! Click here to claim your reward now")) |