Instructions to use Martinagg/toxic-tfidf-lr with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use Martinagg/toxic-tfidf-lr with Scikit-learn:
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("Martinagg/toxic-tfidf-lr", "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
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-learnTfidfVectorizer, word unigrams and bigrams,min_df=5, 200,000 features.classifier.joblib: scikit-learnLogisticRegression, 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
- -