All projects
Machine Learning/Natural language processing /Project 07 of 10 M.S. coursework

Sentiment Analysis with BiLSTM

A Bidirectional LSTM classifier that labels movie-review text as positive or negative, from tokenization and sequence preparation through held-out evaluation.

Business impact

A team considering feedback triage can use the test counts to judge how much reading the classifier would create.

78.57%Accuracy on 98 test reviews
0.7789Positive-class F1
997Records after deduplication

Business question

Can a compact recurrent neural network classify sentiment in short movie reviews?

Approach

How the work was done

  • Parsed 1,000 individual IMDb excerpts and removed three exact duplicate pairs. Grouped splits keep identical cleaned texts together: 799 training, 100 validation and 98 test reviews.
  • Fitted the vocabulary on training text only and padded sequences to 50 tokens, covering all cleaned training reviews. The saved tokenizer and preprocessing metadata accompany the model.
  • Trained a 100-dimension embedding and 128-unit bidirectional LSTM with a 64-unit dense layer, dropout, sigmoid output, and early stopping.

Results

What the analysis shows

  • On the held-out test set, 77 of 98 predictions were correct: accuracy 78.57%, positive-class precision 0.7255, recall 0.8409 and F1 0.7789 at a 0.5 threshold.
  • The negative-review queue contained 47 reviews: 40 negative and 7 positive. It caught 40 of 54 negative reviews and missed 14.
  • The trained Keras model is included in the repository so it can be inspected or loaded without retraining.

From the project

Held-out errors and validation during training

Confusion matrix for 98 reviews: 40 negative and 37 positive classified correctly, with 14 negative and 7 positive reviews misclassified.

The manual-review workload

Negative predictions flag 47 of 98 reviews. The queue contains 40 actual negative reviews and 7 positive reviews; 14 negative reviews are missed.

Training and validation curves across five epochs; validation loss selects the restored epoch 3 weights.

Training fit and unseen reviews

Training continued for five epochs and restored the epoch 3 weights with the lowest validation loss. The later divergence shows why fitting the training reviews alone is not enough.

Business relevance

What this makes easier to decide

The model offers a repeatable way to summarize sentiment from text, with a clear precision-recall tradeoff to consider before using the labels for customer-experience monitoring.