radwa-f's picture
Update README.md
5b3fa4c verified
metadata
tags:
  - text-classification
  - lstm
  - keras
  - tensorflow
  - sentiment-analysis
  - imdb
datasets:
  - imdb
language: en
metrics:
  - accuracy
library_name: keras
pipeline_tag: text-classification

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

Amine Boktaya

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:

Related Projects:

  • Riot Detection System (DeBERTa for social media classification)
  • Tweet Detoxification (BART for style transfer)

Author

Radwa Fattouhi - ENSA El Jadida, Morocco