Spam Detection Model

TF-IDF + Random Forest classifier for English email and SMS spam.

Model

Algorithm Random Forest (100 trees, class_weight=balanced)
Features TF-IDF, 3000 unigrams, min_df=2
Training rows 235,449
F1 (random split) 0.974
Language English only

Files

file description
model_parts/part_aa .. part_ay the model, split into 25 parts
confusion_matrix.png confusion matrix on the test split
skeleton.py training script

The model is stored as 25 parts because a single-file upload of 232 MB was cut off mid-transfer. Each part is a byte-range chunk of spam_model.joblib.gz.

How to load

import gzip, joblib

parts = [f"model_parts/part_{s}" for s in
         ["aa","ab","ac","ad","ae","af","ag","ah","ai","aj",
          "ak","al","am","an","ao","ap","aq","ar","as","at",
          "au","av","aw","ax","ay"]]

blob = b"".join(
    hf_hub_download("Skibidibois2000/spam-detection-model", p)
    for p in parts
)
bundle = joblib.load(gzip.decompress(blob))

prob = bundle["model"].predict_proba(
    bundle["vectorizer"].transform(["your message"])
)[0][1]
print("SPAM" if prob >= bundle["threshold"] else "HAM")

With the huggingface_hub library:

from huggingface_hub import hf_hub_download

Note on reported accuracy

The 0.974 F1 comes from a random 80/20 split, which places near-duplicate messages from the same corpus on both sides. Treat it as an optimistic figure.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support