🔴 Live Demo: Click here to try the App
A Deep Learning project that performs sentiment analysis on movie reviews using the IMDB dataset. This project utilizes a Simple RNN (Recurrent Neural Network) built with TensorFlow/Keras and features a user-friendly web interface deployed using Streamlit.
The goal of this project is to classify movie reviews as either Positive or Negative. The model processes natural language text, converting words into integer sequences, and uses a Recurrent Neural Network to understand the context and sentiment of the review.
- Deep Learning Model: Built using a Simple RNN architecture suitable for sequential text data.
- Dataset: Trained on the standard IMDB dataset (25,000 training reviews).
- Text Preprocessing: Implements tokenization, decoding, and sequence padding to handle varying review lengths.
- Visualization: Utilizes TensorBoard to track training metrics (loss and accuracy) over epochs.
- Deployment: Includes a Streamlit web application for real-time, interactive sentiment prediction.
- Python
- TensorFlow / Keras (Model building & training)
- NumPy (Data manipulation)
- Streamlit (Web interface)
- TensorBoard (Performance visualization)
| File Name | Description |
|---|---|
IMDB_rnn.ipynb |
Jupyter Notebook for data loading, preprocessing, model training, and saving the model. |
main.py |
The Streamlit application script that loads the trained model and creates the web interface. |
prediction.ipynb |
A testing notebook to load the model and run predictions on raw text examples. |
simple_rnn_imdb.h5 |
The saved pre-trained model file generated after training. |
requirements.txt |
List of dependencies required to run the project. |
logs/ |
Directory containing TensorBoard logs for visualization. |
git clone [https://github.com/yourusername/imdb-sentiment-analysis.git](https://github.com/yourusername/imdb-sentiment-analysis.git)
cd imdb-sentiment-analysis
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
Install the required libraries using the requirements file:
pip install -r requirements.txt
Note: Your requirements.txt should typically include:
numpytensorflowstreamlit
If you want to retrain the model from scratch, run the IMDB_rnn.ipynb notebook. This will generate the simple_rnn_imdb.h5 file and TensorBoard logs.
To view the training graphs (Accuracy vs. Loss):
tensorboard --logdir=logs/fit
Run the Streamlit application to use the model interactively:
streamlit run main.py
Once the app is running, enter any movie review in the text box and click Classify to see if the sentiment is Positive or Negative.
The model consists of the following layers:
- Embedding Layer: Converts integer-encoded words into dense vectors of fixed size (128).
- SimpleRNN Layer: A recurrent layer with 128 units (ReLU activation) to capture sequential patterns.
- Dense Layer: A single output unit with Sigmoid activation to output a probability score (0 to 1).
The model achieves a validation accuracy of approximately 83% on the IMDB dataset.
Created by Ritee