SentimentPro is a modern Flask web application for analyzing the sentiment of user reviews. Upload text or Excel/CSV files, and visualize sentiment breakdowns with beautiful interactive charts.
- Instant Sentiment Prediction: Enter a review and get real-time sentiment analysis (Good, Bad, Neutral).
- Bulk Analysis via Excel/CSV Upload: Upload files and see a breakdown of review sentiments.
- Interactive Charts: Visualize sentiment distribution with clear, modern charts.
- Clean, Responsive UI: Built with Bootstrap and custom styles for a seamless experience.
SentimentPro is a modular Flask web app with a clear separation between the web interface, preprocessing, and machine learning model. It uses NLTK for text processing and scikit-learn for sentiment prediction.
- Model Type: Multinomial Naive Bayes classifier (scikit-learn)
- Training Data: Drugs.com Drug Review Dataset, combining both train and test splits.
- Data Size: ~215,000+ user reviews of medications.
- Labeling:
- Reviews are labeled as:
positiveif the rating is 8 or abovenegativeif the rating is 4 or belowneutralotherwise
- Reviews are labeled as:
- Text Processing:
- Reviews are cleaned, tokenized, lowercased, and filtered for stopwords/punctuation using NLTK.
- Features are extracted using CountVectorizer.
- Prediction:
- The model predicts whether a review is positive, negative, or neutral based on the text content.
- It is a real-world, large-scale dataset of user experiences with medications, making it ideal for demonstrating general sentiment analysis workflows.
- The model is generic and can be retrained on your own labeled review data for other domains (e.g., product reviews, movie reviews, etc.)
flowchart TD
User["User (Web Browser)"] -->|HTTP| FlaskApp["Flask Web App"]
FlaskApp -->|Text Input| Preprocess["Text Preprocessing (NLTK)"]
Preprocess -->|Features| Model["Trained ML Model (scikit-learn)"]
Model -->|Prediction| FlaskApp
FlaskApp -->|HTML Response| User
FlaskApp -->|Excel Upload| Pandas["Pandas Data Processing"]
Pandas --> Preprocess
flowchart LR
A["User submits review"] --> B["Text cleaned & tokenized (NLTK)"]
B --> C["Stopwords & rare words removed"]
C --> D["Vectorized (CountVectorizer)"]
D --> E["Prediction (MultinomialNB)"]
E --> F["Result shown in UI"]
- Python 3.8+
- pip
- (Recommended) Create and activate a virtual environment
pip install -r requirements.txt# Activate your virtual environment if needed
export FLASK_APP=app.py
flask runVisit http://127.0.0.1:5000 in your browser.
You can deploy SentimentPro to Render as a free or paid web service.
- Ensure these files are present in your repo root:
app.py,requirements.txt,Procfile,render.yaml,Model.pickle,cv1,text_utils.py, and thetemplates/andstatic/folders.
- Push your code to GitHub.
- Create a new Web Service on Render:
- Connect your GitHub repo
- Render will auto-detect
render.yamland build your app - The service will use
gunicorn app:appto start (seeProcfile/render.yaml)
- Access your app at the Render-provided URL.
Note: Model.pickle and cv1 must be present in the root directory for the app to work.
- Use a WSGI server like Gunicorn (see
Procfilefor Heroku/Render) - Ensure
Model.pickleandcv1are present in the root directory
├── app.py # Main Flask application
├── text_utils.py # Text processing utilities
├── requirements.txt # Python dependencies
├── Procfile # For deployment (Heroku/Render)
├── Model.pickle # Trained ML model (required for prod)
├── cv1 # Trained vectorizer (required for prod)
├── static/
│ ├── icon.png # App icon
│ ├── style.css # Custom styles
│ └── ... # Other images/assets
├── templates/
│ ├── home.html # Main page
│ ├── pie_chart.html # Excel chart page
│ ├── result.html # Prediction result page
│ └── about.html # About page
- Developed by Atul Kumar and contributors.
- Built with Flask, scikit-learn, pandas, Chart.js, Bootstrap.
For questions or contributions, open an issue or pull request.