Music


Meme of the Day

Source r/cryptocurrencymemes

How to Perform Crypto Twitter Sentiment Analysis – Python App

Last updated on July 21st, 2023 at 09:01 pm

Twitter can be a very convoluted place. That is why we have developed this Crypto Twitter Sentiment Analysis Python app to help you search for the current sentiment for any crypto.

Requirements


Twitter-roBERTa-base for Sentiment Analysis

The algorithm we will be using for our sentiment analysis is Twitter-roBERTa-base. It is trained on ~58M tweets and finetuned with the TweetEval benchmark. In short, this algorithm recognises and classifies tweets based on emotion, emojis, hate, irony, offensive, sentiment, and stance. You can read a paper on TweetEval here.


How to Setup Crypto Twitter Sentiment Analysis

  1. Download the ‘crypto-sentiment-analysis’ folder from https://github.com/rlm42/crypto-sentiment-analysis. (Click Code then Download ZIP). Unzip the downloaded folder
  2. Create a new app on the Twitter Developer portal. Copy your API Key and API Key Secret and paste them inside ‘tweepy.0AuthHandler’ in the app.py file. Also generate and copy and paste your Access Token and Access Token Secret and paste inside ‘auth.set_access_token’
    • Twitter API Authentication
  3. Do the same inside the appWordCloud.py file.
    • Twitter API Authentication2
  4. Replace the News API key with your own inside app.py
    • News API Key
  5. Install the latest version of CUDA from: https://developer.nvidia.com/cuda-downloads
  6. Open Command Prompt
  7. Browse to the extracted folder, click and copy the folder location
    • Type ‘cd’ in Command Prompt, paste the folder location and press enter
  8. Install the appropriate version of PyTorch from: https://pytorch.org/get-started/previous-versions/
    • In my case, I have Windows and CUDA 11 so I copy and run the following in CMD ‘pip install torch==1.12.1+cu116 torchvision==0.13.1+cu116 torchaudio==0.12.1 –extra-index-url https://download.pytorch.org/whl/cu116’
  9. Run ‘pip install flask pandas transformers numpy scipy matplotlib’ to install all the required python libraries
  10. Run ‘python app.py’
    • If everything is installed correctly it should return no errors and start downloading the language model, it will take a few minutes
    • You should get ‘Running on http://127.0.0.1:5000’ when it is finished
  11. Open your internet browser and navigate to ‘localhost:5000/tweets‘. You should see the following:
App Screenshot
App UI

How to Update the Word Cloud Image

  1. Open another Command Prompt window
  2. ‘cd’ into the app folder again
  3. Run ‘pip install nltk’
  4. Run ‘python’ to start a python environment
  5. In the python environment run ‘nltk.download(‘stopwords’)’
  6. When it has finished downloading, type ‘exit()’ and press enter to exit the python environment
  7. Run ‘appWordCloud.py’. After a minute or two an image should pop up. This is updating the app’s trending word cloud image
  8. Refresh your ‘localhost:5000/tweets‘ page it should have the new updated word cloud image

How to Search for a Ticker

Type the ticker you want to search for and click search. After a minute or two, you will see the following screen. It shows the user, tweet content, sentiment, weight, number of Favorites, and the number of retweets for each tweet. Navigating to the Sentiment Analysis tab will split the tweets between norma and news tweets, showing corresponding sentiment bar charts.

BSC Search Results
‘BSC’ Search Results
BSC Sentiment Analysis
‘BSC’ Sentiment Analysis

Leave a Reply

Your email address will not be published. Required fields are marked *

AI Chatbot Avatar