This project demonstrates how to build a deep learning model using an LSTM (Long Short-Term Memory) neural network for sentiment analysis of movie reviews. The model is trained on the IMDB dataset to classify movie reviews as positive or negative.
Sentiment analysis is a common natural language processing (NLP) task that involves classifying text into positive or negative sentiments. This project uses a deep learning approach with a Bidirectional LSTM neural network to perform sentiment analysis on movie reviews from the IMDB dataset. LSTMs are well-suited for this task because they are capable of learning long-term dependencies in sequential data.
Ensure you have the following installed:
If you haven’t installed TensorFlow and Matplotlib yet, you can do so using pip:
pip install tensorflow matplotlib
Clone the Repository:
Clone the repository to your local machine:
git clone https://github.com/your-username/sentiment-analysis-lstm.git
Navigate to the Directory:
Go to the project directory:
cd sentiment-analysis-lstm
Run the Script:
Run the script using Python:
python sentiment_analysis_lstm.py
When you run the script, it will:
The script will produce outputs similar to:
Test Accuracy: The accuracy of the model on the test dataset, for example:
Test Accuracy: 0.86
Training and Validation Curves: Plots of accuracy and loss over the training epochs.
Predicted Sentiment: Displays the predicted sentiment (positive or negative) for a new review.
Predicted Sentiment: Positive
To predict the sentiment of a new movie review, you can modify the new_review
variable in the script:
new_review = "This movie was fantastic! I really enjoyed the story and the acting was superb."
Run the script again to see the predicted sentiment.
Contributions are welcome! If you have ideas for new features, improvements, or bug fixes, please feel free to open an issue or create a pull request.
git clone https://github.com/your-username/sentiment-analysis-lstm.git
git checkout -b feature/your-feature-name
git commit -m "Add: feature description"
git push origin feature/your-feature-name
This project is licensed under the MIT License - see the LICENSE file for details.
Thank you for using the Sentiment Analysis with LSTM! If you have any questions or feedback, feel free to reach out. Happy coding! 😊