Live Demo: https://moviesentiment-analyzer.streamlit.app/
A machine learning web application built with Streamlit that analyzes the sentiment of movie reviews. It predicts whether a review is Positive 😊 or Negative 😞 using a variety of classic machine learning and deep learning models.
- Multiple Models: Choose from Logistic Regression, Decision Tree, Random Forest, RNN, and LSTM to analyze reviews.
- Model Comparison: Compare the performance and predictions of all models side-by-side.
- Interpretability:
- Linear Models: Highlights the exact words that influenced the prediction (positive or negative impact).
- Tree Models: Displays the global top 20 most important features.
- Interactive UI: Simple, user-friendly Streamlit interface with real-time confidence scores.
- Frontend: Streamlit
- Machine Learning: Scikit-Learn (Logistic Regression, Decision Trees, Random Forests)
- Deep Learning: PyTorch (RNN, LSTM)
- Data Processing: Pandas, NumPy
- Visualization: Matplotlib, Seaborn, Wordcloud
movie_sentiment_analysis/
│
├── app/
│ └── main.py # Streamlit application
├── models/ # Pre-trained models (.joblib, .pt)
├── notebooks/ # Jupyter notebooks for EDA and Model Training
│ ├── 01_data_inspection_and_eda.ipynb
│ └── machine_learning_models.ipynb
├── data/ # Raw and processed datasets
│ ├── raw/
│ └── processed/
├── src/ # Helper scripts
│ └── download_models.py
├── pyproject.toml # Project configuration
└── requirements.txt # Project dependencies
Ensure you have Python >= 3.12 installed.
-
Clone the repository:
git clone https://github.com/your-username/movie_sentiment_analysis.git cd movie_sentiment_analysis -
Create a virtual environment (optional but recommended):
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install the dependencies:
pip install -r requirements.txt
To start the Streamlit web application, run the following command from the root directory:
streamlit run app/main.pyThe app will automatically open in your default web browser at http://localhost:8501.
This application dynamically loads machine learning models from Hugging Face Hub (Repository: monusharma21/portfolio).
When you start the application, it will automatically download the required model files if they are not already present in the models/ directory:
logistic_model.joblibdecision_tree_model.joblibrandom_forest_model.joblibrnn_model.ptlstm_model.pt
This setup keeps the repository lightweight and makes deployment straightforward!
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source and available under the MIT License.