This project utilizes Hugging Face's Transformers library to perform sentiment analysis on financial news headlines. The model predicts the sentiment of given text and provides a confidence score for its classification.
- Uses Hugging Face Transformers to analyze sentiment.
- Implements the BERT-based multilingual sentiment model (
nlptown/bert-base-multilingual-uncased-sentiment
). - Processes a list of financial news headlines and classifies their sentiment.
- Outputs the predicted sentiment label and confidence score.
- Python
- Hugging Face Transformers
Ensure you have Python (version 3.x) installed on your system.
- Clone the repository:
git clone https://github.com/yourusername/sentiment-analysis.git
- Navigate to the project directory:
cd sentiment-analysis
- Install the required dependencies:
pip install transformers
- Run the script:
python sentiment_analysis.py
- The script contains a predefined list of financial headlines.
- It processes each headline using the sentiment analysis model.
- The predicted label and confidence score are displayed in the console.
Headline 1: Predicted Label - 4 stars, Confidence Score - 0.85 - Microsoft-Activision deal back in hands of UK regulator after court pauses appeal
Headline 2: Predicted Label - 2 stars, Confidence Score - 0.76 - SBB, Brookfield end talks on EduCo stake sale, shares tumble
...
- You can modify the
model_name
variable to use a different sentiment analysis model from Hugging Face. - Update the
headlines
list with your own text inputs.
MIT License © 2024 Your Name