This project is a Twitter Sentiment Analysis System built using Streamlit, Plotly, and yFinance. It helps to analyze the sentiment of tweets from specific Twitter accounts over time and compare it with the Bitcoin price. The sentiment analysis system visualizes sentiment trends and allows for the download of tweets with associated sentiment scores in CSV format.
- Sentiment Score Visualization: Analyze and display the sentiment score of tweets from multiple Twitter accounts.
- Bitcoin Price Chart: Fetch and display Bitcoin's historical prices for a selected date range.
- Sentiment Score Distribution: Generate a pie chart to visualize the distribution of sentiment scores across various categories (e.g., Extremely Bullish, Neutral, Bearish, etc.).
- Zone Highlighting: Add highlighted zones for different sentiment ranges (e.g., Bearish, Bullish) on the sentiment score line chart.
- Data Export: Export tweet data along with the calculated sentiment scores and labels to a CSV file.
To run this project locally, follow these steps:
- Clone the repository:
git clone https://github.com/your-username/twitter-sentiment-analysis.git cd twitter-sentiment-analysis
- Install the required dependencies:
pip install -r requirements.txt
- Run the Streamlit app:
streamlit run app.py
- Optionally, if you're behind a proxy, set up your proxy (replace 33210 with your port number):
os.environ['https_proxy'] = 'http://127.0.0.1:33210'
├── app.py # Main application file
├── sentiment_analyzer.py # Sentiment analysis module
├── requirements.txt # Python dependencies
└── README.md # Project documentation
Enter the Twitter handle of the account you'd like to analyze (without the '@' symbol) and click Add Tweets.
The system will fetch recent tweets from the account and perform sentiment analysis on them.
Use the Start Date and End Date inputs to filter both the sentiment scores and Bitcoin price data to your desired time range.
The system will fetch Bitcoin prices using the yFinance API and display a line chart showing Bitcoin’s performance over time for the selected date range.
After adding one or more Twitter accounts, the sentiment score chart will display the sentiment trend for each account over time, with an Overall score if multiple accounts are added.
The chart includes colored zones for different sentiment ranges (e.g., Extremely Bearish, Neutral).
After tweets are analyzed, you can download the data (tweet content, sentiment scores, and labels) in CSV format by clicking the Download Tweet Data button.
This project makes use of the following libraries:
-
Streamlit: Framework for building data applications.
-
Plotly: Visualization library for interactive charts.
-
yFinance: Yahoo Finance API for fetching stock and cryptocurrency data.
-
Tweety: Python library for fetching tweets from Twitter.
-
Pandas: Data manipulation and analysis library.
If you'd like to support me with cryptocurrency, you can donate using the QR code below:
Feel free to scan the QR code with your wallet app!