A Streamlit web app that predicts whether a movie review is positive 👍 or negative 👎 using a Simple RNN model trained on the Keras IMDB sentiment dataset.
Simple_RNN_imple/
├── app.py # Streamlit application
├── SimpleRNN.h5 # Trained Simple RNN sentiment model
├── requirements.txt # Python dependencies for deployment
├── README.md # Project documentation
├── SimpleRNN_imple.ipynb # Model training notebook
├── prediction.ipynb # Prediction/testing notebook
└── embedding.ipynb # Word embedding practice notebook
- 🔍 Predicts movie review sentiment as positive or negative
- 📊 Shows confidence, positive probability, and negative probability
- 📝 Includes ready-made positive and negative example reviews
- ⚡ Uses cached model loading for smoother Streamlit deployment
- 🧠 Handles unknown words and vocabulary limits consistently with the IMDB dataset
User Input → Lowercase & Tokenize → Map to IMDB Word Index
→ OOV Handling → Pad to 500 tokens → SimpleRNN.h5 → Prediction
- User enters a movie review in the Streamlit app
- Text is lowercased and tokenized
- Tokens are mapped to the Keras IMDB word index
- Unknown or out-of-vocabulary words are mapped to the OOV token
- The sequence is padded to
500tokens SimpleRNN.h5predicts the positive-class probability- Negative probability is calculated as
1 - positive_probability
1. Clone the repository and navigate into the project folder:
git clone <your-repo-url>
cd Simple_RNN_imple2. Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate3. Install dependencies:
pip install -r requirements.txt4. Start the Streamlit app:
streamlit run app.py5. Open in your browser:
http://localhost:8501
Try these in the app to test the model:
| Sentiment | Example |
|---|---|
| ✅ Positive | This movie was fantastic and I loved every minute of it. |
| ❌ Negative | bad awful boring terrible horrible waste worst dull poor disappointing annoying pointless |
| 🔴 Strong Negative | The movie was bad bad bad bad bad bad bad bad bad bad bad bad bad bad bad bad bad bad bad bad. |
The model output is a sigmoid value, representing the probability of the positive class:
positive_probability >= 0.5 → ✅ Positive
positive_probability < 0.5 → ❌ Negative
negative_probability = 1 - positive_probability
| Technology | Purpose |
|---|---|
| 🐍 Python | Core language |
| 🔶 TensorFlow / Keras | Model training & inference |
| 🎈 Streamlit | Web application framework |
| 🧠 Simple RNN | Sentiment classification model |
| 📦 Keras IMDB Dataset | Training data |
- Keras IMDB Dataset — https://keras.io/api/datasets/imdb/
- TensorFlow / Keras — https://www.tensorflow.org/
- Streamlit — https://streamlit.io/