sentivity commited on
Commit
973460b
·
verified ·
1 Parent(s): 5c05c21

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -48,7 +48,12 @@ def predict_sentiment(text):
48
  input_ids, attention_mask = encoded_input["input_ids"], encoded_input["attention_mask"]
49
  with torch.no_grad():
50
  score = score_model(input_ids, attention_mask)[0].item()
51
- return score
 
 
 
 
 
52
 
53
  def fetch_articles(ticker):
54
  POLYGON_API_KEY = os.get_env('poly_api')
 
48
  input_ids, attention_mask = encoded_input["input_ids"], encoded_input["attention_mask"]
49
  with torch.no_grad():
50
  score = score_model(input_ids, attention_mask)[0].item()
51
+ min_val, max_val = 0.3, 0.9
52
+ scaled_score = (score - min_val) / (max_val - min_val)
53
+ # Clip to ensure it stays within [0, 1] in case original score was outside [0.3, 0.9]
54
+ scaled_score = max(0.0, min(1.0, scaled_score))
55
+
56
+ return scaled_score
57
 
58
  def fetch_articles(ticker):
59
  POLYGON_API_KEY = os.get_env('poly_api')