A simple Flask-based web application and API for classifying hate speech using a Logistic Regression model trained on TF-IDF vectorization.
- Python 3.10+
- Docker (optional, if deploying via container)
- Dataset
Clone using SSH:
git clone git@github.com:helinatefera/Hate-Speech-Classification.git
cd Hate-Speech-ClassificationClone the repository and install dependencies:
pip install -r requirements/local.txtTo train the model on the preprocessed dataset:
python3 train.pyThis will generate a pipeline.joblib file that includes both the TF-IDF vectorizer and the trained classifier.
Once the model is trained, you can test it using:
python3 predict.pyYou will get a response like:
Positive (non-hate) (0.95 confidence)
Run the Flask app:
python app/main_app.pyThe app provides:
docker build -t hate-speech-app .docker run -d -p 8000:5000 hate-speech-appThen visit:
http://localhost:8000
GET /api/predict?text=I love youPOST /api/predict
Content-Type: application/json
{
"text": "I hate you"
}MIT License © helinatefera
👤 Helina Tefera
✉️ E-Mail
📱 Phone
