TF-IDF + logistic regression toxicity baseline

Baseline for the capstone project Trust in Automated Moderation of Toxic Comments (ECE 4424 / CS 4824). Code: https://github.com/martinagg7/ML-ToxicModeration

  • vectorizer.joblib: scikit-learn TfidfVectorizer, word unigrams and bigrams, min_df=5, 200,000 features.
  • classifier.joblib: scikit-learn LogisticRegression, C = 30 (chosen on validation PR-AUC).
  • Trained on Jigsaw Unintended Bias (train.csv, 80% split grouped by article), label = target โ‰ฅ 0.5.
  • Saved with scikit-learn 1.9.1: load it with the same version.

Test set (177,635 comments, threshold 0.5): precision 0.73, recall 0.53, F1 0.61, ROC AUC 0.93, PR-AUC 0.69.

Identity words have positive weights, so the model often blocks innocent comments that mention race or religion.

Usage

import joblib
from huggingface_hub import hf_hub_download

vectorizer = joblib.load(hf_hub_download("Martinagg/toxic-tfidf-lr", "vectorizer.joblib"))
classifier = joblib.load(hf_hub_download("Martinagg/toxic-tfidf-lr", "classifier.joblib"))
classifier.predict_proba(vectorizer.transform(["You are an idiot"]))[:, 1]

Note: .joblib files are pickles; only load them from sources you trust.

Downloads last month
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support