LSTM IMDB Sentiment Analysis - Baseline Model
Traditional LSTM model for binary sentiment classification achieving 89% accuracy on IMDB movie reviews.
This model serves as a baseline in a comparative study demonstrating the superiority of transfer learning (DeBERTa: 96%) over traditional approaches.
Quick Start
import pickle
from tensorflow import keras
from huggingface_hub import hf_hub_download
# Download
model_path = hf_hub_download("radwa-f/LSTM-IMDB-SentimentAnalysis", "model.h5")
tok_path = hf_hub_download("radwa-f/LSTM-IMDB-SentimentAnalysis", "tokenizer.pkl")
# Load
model = keras.models.load_model(model_path)
with open(tok_path, 'rb') as f:
tokenizer = pickle.load(f)
# Predict
text = "This movie was amazing!"
seq = tokenizer.texts_to_sequences([text])
padded = keras.preprocessing.sequence.pad_sequences(seq, maxlen=200)
pred = model.predict(padded)[0][0]
print(f"{'POSITIVE' if pred > 0.5 else 'NEGATIVE'} ({pred:.2%})")
Performance Comparison
| Model | Accuracy | Type |
|---|---|---|
| LSTM (this) | 89% | Traditional RNN |
| DeBERTa | 96% | Transfer Learning |
| Difference | -7% |
Architecture
Embedding(vocab_size, 128)
LSTM(128)
Dense(64, relu)
Dropout(0.5)
Dense(1, sigmoid)
Training
- Dataset: IMDB (50K reviews)
- Framework: Keras/TensorFlow
- Loss: Binary Crossentropy
- Optimizer: Adam
Model Creators
Radwa Fattouhi
- Final-year Software Engineering Student
- École Nationale des Sciences Appliquées (ENSA), El Jadida, Morocco
- Email: [email protected]
- LinkedIn: radwa-fattouhi
- GitHub: radwa-f
Amine Boktaya
- Final-year Software Engineering Student
- École Nationale des Sciences Appliquées (ENSA), El Jadida, Morocco
- Email: [email protected]
- LinkedIn: amine-boktaya
- GitHub: BoktayaAmine
Citation
If you use this model in your research, please cite:
@misc{fattouhi2025imdb,
author = {Fattouhi, Radwa and Boktaya, Amine},
title = {LSTM IMDB Sentiment Analysis: Transfer Learning vs Traditional Approaches},
year = {2025},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/radwa-f/DeBERTA-Imdb-SentimentAnalysis}}
howpublished = {\url{https://huggingface.co/radwa-f/LSTM-IMDB-SentimentAnalysis}}
}
Related Work
Published Research:
- AgriAlertX: Climate-driven disaster prevention for agriculture
- Journal: SoftwareX (Elsevier)
- DOI: 10.1016/j.softx.2025.102350
Related Projects:
- Riot Detection System (DeBERTa for social media classification)
- Tweet Detoxification (BART for style transfer)
Author
Radwa Fattouhi - ENSA El Jadida, Morocco
- Downloads last month
- -