This repository is about IMDb movie review sentiment classification with a recurrent neural network ( RNN ) built in PyTorch.
The notebook loads the IMDb dataset, cleans the review text, converts the labels to numeric form, vectorizes the reviews with TF-IDF, and trains an RNN to predict positive or negative sentiment.
- Load the dataset from
IMDB Dataset.csv. - Inspect the data, remove duplicates, and check for missing values.
- Preprocess the review text by lowercasing, removing URLs, punctuation, HTML tags, and stop words, then applying stemming.
- Encode sentiment labels and vectorize the cleaned text with TF-IDF.
- Split the data into train and test sets.
- Build and train a PyTorch RNN model.
- Evaluate the model with accuracy on the test set.
RNN_sentiment_analysis.ipynb- main notebook with the full workflowIMDB Dataset.csv- input dataset used by the notebook
The notebook uses:
- pandas
- numpy
- scikit-learn
- nltk
- torch
- Open
RNN_sentiment_analysis.ipynbin Jupyter or VS Code. - Make sure
IMDB Dataset.csvis in the same folder as the notebook. - Install the required Python packages if needed.
- Run the notebook cells from top to bottom.
- The notebook is written as an end-to-end experiment and is best run sequentially.
- NLTK stopwords and tokenizers may need to be downloaded before preprocessing.