Comprehensive NLP project analyzing 2,000 movie reviews with advanced error analysis and statistical evaluation
This project implements VADER (Valence Aware Dictionary and sEntiment Reasoner) sentiment analysis on the famous IMDb Movie Reviews Dataset containing 2,000 movie reviews. The goal is to automatically classify movie reviews as positive or negative sentiment and evaluate the performance against human-labeled ground truth.
- Dataset: 2,000 IMDb movie reviews (1,000 positive, 1,000 negative)
- Algorithm: NLTK VADER Sentiment Intensity Analyzer
- Performance: 63.67% accuracy with detailed analysis
- Challenge: Understanding complex human semantics in movie reviews
- Analysis: 20+ professional visualizations and statistical tests
Unlike simple text classification, this project tackles the challenging problem of sentiment analysis in movie reviews, where:
- Reviews often contain mixed sentiments
- Sarcasm and irony are common
- Context matters more than individual words
- Final judgments may appear only at the end of long reviews
โ
Overall Accuracy: 63.67%
๐ Total Reviews Analyzed: 1,938
โ๏ธ Correct Predictions: 1,234
โ Incorrect Predictions: 704
๐ Performance Breakdown:
โข Precision (Negative): 72.0%
โข Precision (Positive): 60.0%
โข Recall (Negative): 44.0%
โข Recall (Positive): 83.0%
โข F1-Score (Macro): 62.0%
Python 3.7+
pip install -r requirements.txt# Clone the repository
git clone https://github.com/Ahmadhammam03/movie-sentiment-analysis.git
cd movie-sentiment-analysis
# Create virtual environment
python -m venv sentiment_env
source sentiment_env/bin/activate # On Windows: sentiment_env\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Download NLTK data
python -c "import nltk; nltk.download('vader_lexicon')"# Launch Jupyter Notebook
jupyter notebook
# Open and run the enhanced notebook
# -> Sentiment-Analysis.ipynbmovie-sentiment-analysis/
โ
โโโ ๐ Sentiment-Analysis.ipynb # Main analysis notebook
โโโ ๐ data/
โ โโโ moviereviews.tsv # Movie reviews dataset
โโโ ๐ผ๏ธ assets/ # Generated visualizations
โ โโโ sentiment_analysis_banner.png # Project banner
โ โโโ confusion_matrix.png # Confusion matrix visualization
โ โโโ sentiment_distribution.png # Data distribution plot
โ โโโ methodology_flow.png # Process flow diagram
โ โโโ error_examples.png # Error analysis examples
โโโ ๐ requirements.txt # Python dependencies
โโโ ๐ README.md # Project documentation
โโโ ๐ LICENSE # MIT License
โโโ ๐ซ .gitignore # Git ignore rules
- Data Loading: Import 2,000 movie reviews from TSV file
- Data Cleaning: Remove NaN values and empty strings
- Quality Assessment: Analyze text length and characteristics
from nltk.sentiment.vader import SentimentIntensityAnalyzer
# Initialize VADER analyzer
sid = SentimentIntensityAnalyzer()
# Generate sentiment scores
scores = sid.polarity_scores(review_text)
# Returns: {'neg': 0.121, 'neu': 0.778, 'pos': 0.101, 'compound': -0.9125}- Classification Metrics: Accuracy, Precision, Recall, F1-Score
- Error Analysis: False positives/negatives with examples
- Statistical Testing: Mann-Whitney U tests for significance
- Visualization: 20+ professional charts and dashboards
- โ High recall for positive reviews (83%) - excellent at finding positive sentiment
- โ Good precision for negative reviews (72%) - confident negative predictions
- โ Fast processing (500+ reviews/second)
- โ No training required - ready-to-use approach
- โ Interpretable results with sentiment components
- โ 542 false positives - struggles with negative reviews containing positive words
- โ Limited context understanding beyond individual words
- โ Difficulty with sarcasm, irony, and mixed sentiments
- โ Challenges with delayed judgment patterns in movie reviews
- Movie reviews exhibit complex sentiment structures not easily captured by lexicon-based methods
- Many reviews discuss positive aspects before delivering negative final judgment
- Context and discourse structure matter more than individual word sentiment
- The decision boundary may need domain-specific optimization
The project includes comprehensive visualizations:
- Dataset Analysis Dashboard (4-panel overview)
- Sentiment Score Analysis (9-panel comprehensive view)
- Performance Evaluation Dashboard (9-panel metrics analysis)
- Error Analysis Visualizations (detailed error patterns)
- Final Summary Dashboard (key findings and recommendations)
- pandas: Data manipulation and analysis
- numpy: Numerical computing
- nltk: Natural Language Processing toolkit with VADER
- scikit-learn: Machine learning metrics and evaluation
- matplotlib/seaborn: Professional data visualization
- scipy: Statistical analysis and significance testing
- Original Dataset: Cornell Movie Review Data v2.0
- Authors: Bo Pang and Lillian Lee (2004)
- Publication: "A Sentimental Education: Sentiment Analysis Using Subjectivity Summarization Based on Minimum Cuts", ACL 2004
- Size: 2,000 movie reviews from IMDb
- Balance: Perfectly balanced (1,000 positive, 1,000 negative)
@InProceedings{Pang+Lee:04a,
author = {Bo Pang and Lillian Lee},
title = {A Sentimental Education: Sentiment Analysis Using Subjectivity Summarization Based on Minimum Cuts},
booktitle = "Proceedings of the ACL",
year = 2004
}- Adjust decision threshold based on domain-specific validation
- Implement preprocessing to handle negations more effectively
- Add movie-specific sentiment lexicon expansions
- Consider sentence-level sentiment analysis for longer reviews
- Implement transformer-based models (BERT, RoBERTa) for better context understanding
- Use ensemble methods combining VADER with other sentiment approaches
- Develop domain-specific models trained on movie review corpora
- Apply attention mechanisms to identify key sentiment-bearing passages
- Sentiment Analysis: Understanding VADER lexicon-based approach
- Data Preprocessing: Cleaning and preparing text data for analysis
- Performance Evaluation: Using comprehensive classification metrics
- Statistical Analysis: Conducting significance tests and error analysis
- Data Visualization: Creating professional, publication-ready charts
- NLP Challenges: Real-world complexities in sentiment analysis
- Human Language: Understanding context and semantic nuances
- Model Limitations: When rule-based systems fall short
- Research Methods: Systematic evaluation and error analysis
Contributions are welcome! Here's how you can help improve this project:
- Add additional sentiment analysis methods for comparison
- Implement deep learning approaches (BERT, RoBERTa)
- Create interactive web interface for real-time analysis
- Add more comprehensive error analysis categories
- Improve documentation and add more examples
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Ahmad Hammam
- GitHub: @Ahmadhammam03
- LinkedIn: Ahmad Hammam
Skills Demonstrated in This Project:
- Advanced Python programming and data analysis
- Natural Language Processing with NLTK
- Statistical analysis and hypothesis testing
- Professional data visualization and storytelling
- Research methodology and systematic evaluation
- Technical documentation and communication
- Cornell University for providing the movie review dataset
- NLTK Team for the excellent VADER sentiment analysis tool
- Open Source Community for making advanced NLP accessible to everyone
โญ If you found this project helpful, please consider giving it a star! โญ
๐ฌ "In the world of sentiment analysis, context is king and VADER is a worthy knight!" ๐ญ