Skip to content

sai-aishwarya-codes/Twitter-sentiment-analysis-using-Python-Machine-Learning

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“Œ Twitter Sentiment Analysis using Python & Machine Learning

Twitter Sentiment Analysis is a powerful Natural Language Processing (NLP) technique used to understand public opinions, emotions, and attitudes expressed in tweets. In this project, we analyze people’s sentiment toward Pfizer COVID-19 vaccines using machine learning models.

The goal is to clean and process tweet data, convert text into meaningful features, build ML models, and classify tweets into Positive, Negative, and Neutral sentiments. The performance of multiple classifiers is compared to identify the most accurate model.

🎯 Project Objectives

Collect and preprocess real-world Twitter data

Perform sentiment classification using Machine Learning

Evaluate different ML algorithms for accuracy

Visualize sentiment distribution and model performance

Identify public perception towards Pfizer vaccines

🧠 Project Workflow Phase Description

  1. Data Collection Dataset sourced from Kaggle containing Pfizer-related tweets
  2. Data Preprocessing Cleaning tweets (removing URLs, stopwords, special characters, stemming, etc.)
  3. Feature Extraction Converting text to numerical features using TF-IDF / Bag-of-Words
  4. Model Training Applying ML algorithms to train sentiment classifier
  5. Model Evaluation Accuracy comparison and confusion matrix for performance analysis
  6. Output Visualization Sentiment results and graphs for insights 🧰 Technologies & Tools Used Category Tools / Libraries Programming Language Python Data Handling Pandas, NumPy Machine Learning Scikit-Learn NLP & Text Processing NLTK, Regex, Stopwords, Stemming Feature Engineering TF-IDF Vectorizer, CountVectorizer Model Evaluation Accuracy Score, Confusion Matrix, Classification Report Visualization Matplotlib, Seaborn, WordCloud Environment Jupyter Notebook / Google Colab πŸ€– Algorithms Used

The following ML models were trained and evaluated:

Logistic Regression

Naive Bayes (MultinomialNB)

Support Vector Machine (SVM)

Random Forest Classifier

Decision Tree Classifier

The model with the highest accuracy is selected as the final sentiment classifier.

πŸ“Š Project Outcomes

βœ… Successfully classified tweets into Positive, Negative, and Neutral sentiment βœ… Identified the sentiment trend towards Pfizer vaccines βœ… Compared models and highlighted the best performing classifier βœ… Visualized sentiment distribution using bar charts and word clouds

Key Insight:

Sentiment analysis showed a mix of opinions, with a significant percentage expressing positive views about Pfizer vaccines, along with some negative concerns and neutral feedback.

πŸ“‚ Project Structure Twitter-Sentiment-Analysis/ β”‚ β”œβ”€β”€ Dataset/ # Kaggle dataset used for training β”œβ”€β”€ notebook.ipynb # Main Jupyter Notebook with code β”œβ”€β”€ models/ # Trained ML models (if saved) β”œβ”€β”€ visuals/ # Charts and WordCloud images β”œβ”€β”€ requirements.txt # Python dependencies └── README.md # Project documentation

πŸš€ How to Run the Project Step 1: Install Dependencies pip install -r requirements.txt

Step 2: Run the Jupyter Notebook jupyter notebook

Step 3: Open the notebook.ipynb and run all cells

πŸ“ˆ Future Improvements

πŸ”Ή Integrate live Twitter API to analyze real-time tweets πŸ”Ή Deploy as a Web App using Flask or Streamlit πŸ”Ή Use Deep Learning models like LSTM, Bi-LSTM, or BERT for higher accuracy πŸ”Ή Multi-class emotion detection (joy, anger, fear, sarcasm, etc.)

πŸ‘©β€πŸ’» Author

Sai Aishwarya Reddy Devarapalli Machine Learning | AI Enthusiast πŸ”— GitHub: https://github.com/sai-aishwarya-codes

About

Twitter-sentiment-analysis-using-Python-Machine-Learning

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published