# Twitter Toxicity Detection: A Flask App for Text Classification

Twitter Toxicity Detection: A Flask App for Text Classification

I built this project to explore how machine learning and natural language processing (NLP) can be used to detect toxic content in text. It provides a simple Flask web interface where users can enter a tweet and receive a toxicity prediction in real time.

The project is intended as a starting point for anyone interested in text classification, NLP, or integrating machine learning models into a web application.

Features

*   Simple Flask web interface
    
*   Analyze tweets or text for toxic language
    
*   Uses pretrained NLP models
    
*   Returns predictions in real time
    
*   Displays different toxicity categories such as abusive language, hate speech, and profanity
    

Getting Started

Clone the repository:

git clone https://github.com/mantreshkhurana/twitter-toxicity-detection-flask.git cd twitter-toxicity-detection-flask

Install the required packages:

pip install -r requirements.txt

Create a .env file and add your configuration:

API\_KEY=your\_api\_key\_here MODEL\_PATH=path\_to\_pretrained\_model

Start the application:

python app.py

Then open your browser and visit:

http://127.0.0.1:5000/

How It Works

The application follows a simple workflow:

1.  Enter a tweet or any text into the web interface.
    
2.  The Flask backend sends the text to a pretrained NLP model.
    
3.  The model analyzes the content and predicts its toxicity.
    
4.  The results are displayed, including toxicity scores and detected categories.
    

Project Structure

twitter-toxicity-detection-flask/ │ ├── app.py ├── templates/ ├── static/ ├── models/ ├── requirements.txt └── README.md

Why This Project?

This project demonstrates how machine learning models can be integrated into a Flask application with a simple user interface. It’s useful for learning about NLP, text classification, and deploying AI models in web applications.

Since it uses pretrained models, you can focus on building and extending the application instead of training models from scratch.

Contributing

The project is open source, and contributions are welcome. If you have ideas for improvements, bug fixes, or additional features, feel free to open an issue or submit a pull request.

License

This project is released under the MIT License, so you’re free to use and modify it for your own projects.

GitHub: https://github.com/mantreshkhurana/twitter-toxicity-detection-flask
