khandelwalkishna15 commited on
Commit
40c7739
1 Parent(s): 4f76b9d

new update

Browse files
Files changed (1) hide show
  1. sentiment_analysis.py +0 -17
sentiment_analysis.py DELETED
@@ -1,17 +0,0 @@
1
- from transformers import AutoTokenizer, AutoModelForSequenceClassification
2
-
3
- # Load pre-trained model and tokenizer
4
- #model_name = "ProsusAI/finbert"
5
- #model_name = "ahmedrachid/FinancialBERT-Sentiment-Analysis"
6
- model_name="mrm8488/distilroberta-finetuned-financial-news-sentiment-analysis"
7
- tokenizer = AutoTokenizer.from_pretrained(model_name)
8
- model = AutoModelForSequenceClassification.from_pretrained(model_name)
9
-
10
- # Example: Classify a financial text
11
- text = "With the launch of Apple Silicon, Apple shares have increased"
12
- inputs = tokenizer(text, return_tensors="pt")
13
- outputs = model(**inputs)
14
- predictions = outputs.logits.argmax(dim=1).item()
15
-
16
- # 'predictions' will contain the sentiment class (e.g., 0 for negative, 1 for neutral, 2 for positive)
17
- print("Predicted sentiment class:", predictions)