Skip to content

The Twitter Sentiment Analysis app predicts whether a tweet has a Positive 😊 or Negative 😞 sentiment using Logistic Regression and Naive Bayes models. It preprocesses text with stemming and stopword removal for better accuracy and provides color-coded visual feedback for easy interpretation.

Notifications You must be signed in to change notification settings

machinelearningprodigy/sentiment-analysis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Twitter Sentiment Analysis with Streamlit πŸ˜ƒ

Welcome to the Twitter Sentiment Analysis project! This application allows you to analyze the sentiment of Twitter comments, predicting whether a comment is Positive 😊 or Negative 😞.

Features ✨

  • Dual Model Predictions: This app uses two powerful machine learning models:

    • Logistic Regression
    • Naive Bayes
  • Text Preprocessing: The app preprocesses the input text using stemming and stopword removal to improve prediction accuracy.

  • User-Friendly Interface: Enter your comment, hit the "Predict Sentiment" button, and instantly see whether the sentiment is positive or negative!

  • Visual Feedback: Sentiment predictions are displayed with clear, color-coded messages and expressive emojis.

How It Works πŸ”

1. Text Preprocessing πŸ› οΈ

The input text goes through several preprocessing steps:

  • Stemming: Words are reduced to their root forms using the Porter Stemmer.
  • Stopword Removal: Commonly used English words that do not contribute much to the meaning (e.g., "the", "is") are removed.

2. Model Prediction πŸ€–

The preprocessed text is then transformed using a vectorizer (vectorizer.pkl) and fed into the machine learning models:

  • Logistic Regression Model (logistic_regression_model.pkl)
  • Naive Bayes Model (naive_bayes_model.pkl)

3. Output 🎯

The sentiment prediction is displayed on the screen:

  • Positive Sentiment: Shown with a green background and a happy emoji 😊.
  • Negative Sentiment: Shown with a red background and a sad emoji 😞.

How to Use the App πŸ“

  1. Enter Your Comment: Type in the comment you want to analyze.
  2. Predict Sentiment: Click the "Predict Sentiment" button.
  3. View Results: See whether your comment is predicted to be positive or negative.

Installation and Setup βš™οΈ

  1. Clone the Repository:
    git clone https://github.com/machinelearningprodigy/sentiment-analysis.git
  2. Navigate to the Project Directory:
    cd twitter-sentiment-analysis
  3. Install the Required Packages:
    pip install -r requirements.txt
  4. Run the Streamlit App:
    streamlit run app.py

Live Demo πŸš€

Check out the live demo of this app here: Twitter Sentiment Analysis

Acknowledgments πŸ™Œ

  • NLTK: For providing tools for natural language processing.
  • Scikit-learn: For machine learning model implementation.
  • Streamlit: For making the web app creation process simple and intuitive.

Happy analyzing! πŸŽ‰

About

The Twitter Sentiment Analysis app predicts whether a tweet has a Positive 😊 or Negative 😞 sentiment using Logistic Regression and Naive Bayes models. It preprocesses text with stemming and stopword removal for better accuracy and provides color-coded visual feedback for easy interpretation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Languages