Twitter Toxicity Detection: A Flask App for Text Classification
Mantresh Khurana is the Founder & CEO of Spyxpo, a visionary entrepreneur, and a full-stack developer with a passion for pushing the boundaries of technology. With expertise in web, mobile, desktop, and embedded systems, he excels at mastering emerging technologies that drive innovation. His work is defined by a commitment to developing cutting-edge solutions that transform industries and shape the future.
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:
How It Works
The application follows a simple workflow:
Enter a tweet or any text into the web interface.
The Flask backend sends the text to a pretrained NLP model.
The model analyzes the content and predicts its toxicity.
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


