This project aims to perform sentiment analysis on tweets obtained from Twitter using Python. Sentiment analysis involves analyzing text data to determine the sentiment expressed, typically as positive, negative, or neutral.
Libraries Used
- Tweepy: Python library for accessing the Twitter API.
- TextBlob: Library for processing textual data, including sentiment analysis.
- WordCloud: Library for generating word clouds from text data.
- Sastrawi: Library for stemming Indonesian words.
- Pandas: Library for data manipulation and analysis.
- NumPy: Library for numerical computing.
- Matplotlib: Library for creating visualizations in Python.
Setup
- Twitter Developer Account: You need to have a Twitter Developer Account and create an application to obtain API keys and access tokens.
- Python Environment: Set up a Python environment with the required libraries installed. You can use
pip
to install the libraries listed above. - Clone Repository: Clone this repository to your local machine.
Functionality
- Fetching Tweets: Uses the Tweepy library to fetch tweets based on a specified search query.
- Text Preprocessing: Cleans and preprocesses the text data by removing special characters, URLs, and stopwords.
- Sentiment Analysis: Utilizes the TextBlob library to perform sentiment analysis on the preprocessed text data. It assigns sentiment polarity scores to each tweet.
- Word Cloud Visualization: Generates a word cloud to visualize the most frequent words in the tweet dataset.
- Sentiment Distribution: Displays the distribution of sentiments (positive, negative, neutral) in the tweet dataset.
Future Improvements
- Implement more advanced text preprocessing techniques.
- Explore deep learning-based sentiment analysis models.
- Enhance visualization capabilities for better insights.
Github: https://github.com/muslimalfatih/ml-playground
Demo: https://ml-playground.vercel.app/twitter-sentiment-analysis/tsa.html