Detect harmful comments for moderation queues while highlighting context, fairness, and appeal workflows.
This is a portfolio-ready supervised-learning workflow built around a current business use case. It shows how to move from a documented data contract to a baseline, a validated model, honest holdout evaluation, and responsible interpretation.
- Learning type: Supervised text
- Primary methods: TF-IDF, Naive Bayes, and logistic regression
- Evaluation: macro F1 and class-level diagnostics
- Decision boundary: Predictions support prioritization and review; they do not replace domain judgment.
The notebook creates a deterministic, domain-shaped demonstration dataset locally. This keeps the project executable and avoids publishing private or questionably licensed data. The schema, target, caveats, and migration path to real data are documented in the notebook.
- Reproducible environment and seed
- Data contract and quality checks
- Exploratory analysis
- Leakage-safe or chronological split
- Baseline and candidate-model comparison
- Holdout metrics and diagnostics
- Explainability or operational interpretation
- Limitations, monitoring, and next steps
The notebook is committed with executed outputs. Open toxic_comment_classification.ipynb to inspect the actual model comparison, plots, holdout metrics, diagnostics, and sample predictions generated from the reproducible demo data.
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r ../requirements.txt
jupyter lab "toxic_comment_classification.ipynb"Run cells from top to bottom. Use the recorded package versions and replace the demo data only after matching the documented schema.
- Python
- pandas and NumPy
- scikit-learn
- Matplotlib and Seaborn
- Jupyter Notebook
- Demo metrics are not production benchmarks.
- Validate on licensed, representative, time-appropriate data.
- Audit leakage, calibration, subgroup behavior, drift, and business error costs.
- Add human-review, monitoring, retraining, and rollback policies before deployment.
Tajamul Khan
