Skip to content

Latest commit

 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

IMDB Sentiment Analysis (RNN)

A recurrent neural network built with PyTorch to classify IMDB movie reviews as positive or negative.

Overview

This project implements a text preprocessing pipeline and an RNN from scratch to perform binary sentiment classification on the IMDB Dataset of 50,000 movie reviews.

Dataset

  • IMDB Dataset of 50K Movie Reviews
  • 49,582 reviews after removing duplicates (25k+ positive, 25k+ negative)
  • Labels encoded via LabelEncoder (positive = 1, negative = 0)

Preprocessing

  • Lowercasing
  • URL removal
  • Punctuation removal
  • HTML tag removal
  • Stopword removal (NLTK)
  • Stemming (Porter Stemmer)
  • Vectorization via TF-IDF (TfidfVectorizer, max 5000 features)

Model Architecture

  • Single-layer RNN (nn.RNN), hidden size 128
  • Fully connected output layer (128 → 1)
  • Sigmoid activation for binary classification

Training

  • Loss function: Binary Cross-Entropy Loss
  • Optimizer: Adam
  • Epochs: 10
  • Batch size: 64

Results

  • Test accuracy: 85.61%

Requirements

torch
scikit-learn
nltk
pandas

Usage

python train.py

Trains the RNN on the preprocessed reviews and evaluates accuracy on the held-out test set.

Author

Samir B K GitHub: github.com/Samir-BK

About

Sentiment analysis on IMDB movie reviews using an RNN built with PyTorch, with TF-IDF vectorization and text preprocessing (achieves 85.61% test accuracy).

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages