Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

Twitter-Sentiment140-Analysis

This project uses an LSTM-based neural network to perform binary classification of the Sentiment140 dataset. The model predicts whether a given tweet expresses positive or negative sentiment.

Features

  • Data Preprocessing: Includes tokenization, cleaning, and lemmatization of tweets to create structured input for the model.
  • Custom Embedding Layer: Utilizes pre-trained GloVe embeddings for word representation, ensuring robust vectorization of textual data.
  • Model Design: A two-layer bidirectional LSTM with dropout for regularization, trained using the Adam optimizer.
  • Performance: Trained on a subset of the Sentiment140 dataset (~1.6M tweets), achieving effective sentiment classification.

Example Predictions

- Sentences closer to **1.0** indicate positive sentiment. - Sentences closer to **0.0** indicate negative sentiment.

Project Highlights

  1. Data Preprocessing:
    • Tokenization using NLTK.
    • Lemmatization with POS tagging.
    • Noise removal (URLs, mentions, punctuation, and stopwords).
  2. Visualization: Generates word clouds of frequent words for exploratory data analysis.
  3. Model:
    • Embedding layer built from GloVe.
    • Bidirectional LSTMs for context-aware text analysis.
    • Dropout for overfitting prevention.
  4. Custom Predictions: Easily classify custom text strings using the trained model.

Results

The model can predict custom sentences with confidence, such as:

print(predict_custom_string("I love chocolate"))  # Output: ~0.93 (positive)
print(predict_custom_string("I hate chocolate"))  # Output: ~0.09 (negative)

Dataset

The Sentiment140 dataset is used for training and testing. It contains 1.6 million tweets labeled as positive (4) or negative (0).

For more details, refer to the notebook.

About

Sentiment analysis of tweets using an LSTM neural network trained on the Sentiment140 dataset with GloVe embeddings.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Contributors

Languages