A sentiment analysis project that classifies movie reviews (specifically from the IMDB dataset) as positive or negative using a Bidirectional LSTM model with TensorFlow/Keras.
classifier.py: Data loading and preprocessing utilities (regex cleaning, encoding).training.py: Script to train the model. It handles text vectorization, model building (Embedding + Bidirectional LSTM), training, and saving the model & tokenizer.testing.py: script to load the trained model and tokenizer to run predictions on input text.dataset/: Directory containing theIMDB Dataset.csv.model/: Directory whereclassifier.kerasandtokenizer.pklare saved.
- Clone the repository (if applicable) or navigate to the project directory.
- Create a virtual environment (optional but recommended):
python -m venv .venv # Windows .venv\Scripts\activate # Mac/Linux source .venv/bin/activate
- Install dependencies:
(Or install via
pip install tensorflow pandas numpy scikit-learn
uv/pipbased onpyproject.toml)
To train the model and save the artifacts:
python training.pyThis will:
- Load the IMDB dataset.
- Preprocess reviews.
- Train the Bidirectional LSTM model.
- Save the model to
./model/classifier.kerasand tokenizer to./model/tokenizer.pkl.
To predict the sentiment of a review:
python testing.pyYou can modify the input text in testing.py to test different reviews.

