A machine learning model that classifies movie reviews as positive or negative, built as a baseline project for Smart India Hackathon.
This project uses TF-IDF vectorization + Logistic Regression to classify sentiment in text reviews. Trained on the IMDB 50K Movie Reviews dataset.
- Test Accuracy: 88.5%
- Precision/Recall: ~0.88-0.90 for both classes (balanced performance)
sentiment-analyzer/ ├── data/ # Dataset (not tracked in git — see setup below) ├── src/ │ ├── load_data.py # Loads raw dataset │ ├── eda.py # Exploratory data analysis │ ├── preprocess.py # Text cleaning │ ├── features.py # TF-IDF feature extraction │ ├── train.py # Model training │ ├── evaluate.py # Model evaluation (metrics, confusion matrix) │ └── predict.py # Interactive prediction script ├── requirements.txt └── README.md
- Clone the repo and create a virtual environment:
python -m venv venv venv\Scripts\activate pip install -r requirements.txt
-
Download the IMDB 50K Movie Reviews dataset and place it at
data/imdb_reviews.csv -
Run the pipeline in order: cd src python preprocess.py python features.py python train.py python evaluate.py python predict.py
TF-IDF is a bag-of-words approach and doesn't capture word order — phrases like "not good" can be misclassified. A future improvement would be n-grams or a sequence model (LSTM/BERT).
TF-IDF is a bag-of-words approach and doesn't capture word order — phrases like "not good" can be misclassified. A future improvement would be n-grams or a sequence model (LSTM/BERT).