Skip to content

A sentiment analysis application using a custom-built Transformer model. This project processes IMDB movie reviews to classify them as positive or negative, leveraging TensorFlow and Keras for deep learning. It includes data preprocessing, model visualization, and interactive user predictions.

Notifications You must be signed in to change notification settings

KonyD/Sentiment-Analysis-Transformer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sentiment Analysis with Transformer

This project implements a sentiment analysis model using a custom Transformer architecture. The model predicts whether a movie review is positive or negative based on the IMDB dataset.

🚀 Features

  • Custom Transformer Model: Built from scratch using TensorFlow and Keras.
  • IMDB Dataset: Preprocessed and padded for consistency.
  • Visualization: Includes loss and accuracy plots for training and validation.

📂 Project Structure

.
├── main.py            # Main script with the Transformer model
├── requirements.txt   # Dependencies for the project
├── .gitignore         # Ignored files for Git
└── README.md          # Project documentation

🛠️ Requirements

Install the dependencies using:

pip install -r requirements.txt

🧪 Usage

  1. Run the main script:

    python main.py
  2. Enter a movie review when prompted, and the model will predict its sentiment.

📊 Visualization

Training and validation metrics are plotted after training:

Loss vs Epochs

Training Loss and Validation Loss

Accuracy vs Epochs

Training Loss and Validation Loss

✍️ Example Output

Enter a film review: This movie was amazing! I loved it.
1/1 ━━━━━━━━━━━━━━━━━━━━ 0s 63ms/step
Prediction result is positive -> score: 0.9998332262039185

📈 Model Summary

The model uses a 4-layer Transformer with multi-head attention and feedforward layers, optimized for binary classification.

📋 Dataset

The project uses the IMDB dataset, which is loaded via TensorFlow's keras.datasets.imdb.

🤝 Contributing

Feel free to fork the repository, submit pull requests, or open issues to contribute to this project.


About

A sentiment analysis application using a custom-built Transformer model. This project processes IMDB movie reviews to classify them as positive or negative, leveraging TensorFlow and Keras for deep learning. It includes data preprocessing, model visualization, and interactive user predictions.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages