Kovila commited on
Commit
004a155
·
1 Parent(s): 762e2c4

sentiment analysis

Browse files
Files changed (2) hide show
  1. app.py +14 -2
  2. requirements.txt +1 -0
app.py CHANGED
@@ -5,6 +5,7 @@ import datetime
5
  from transformers import pipeline
6
  from transformers import AutoTokenizer, AutoModelForSequenceClassification
7
  import torch
 
8
  import streamlit as st
9
 
10
 
@@ -87,8 +88,19 @@ st.write(news)
87
 
88
  st.header('Financial News Sentiment')
89
  with st.spinner('finbert model getting sentiment...'):
90
- postive, neutral, negative = get_news_sentiment(news)
91
- st.bar_chart(x=['positive', 'neutral', 'negative'], y=[postive, neutral, negative], color=[0,1,2])
 
 
 
 
 
 
 
 
 
 
 
92
 
93
  st.header('Financial News Summary')
94
  with st.spinner('facebook bart model is summarizing the news...'):
 
5
  from transformers import pipeline
6
  from transformers import AutoTokenizer, AutoModelForSequenceClassification
7
  import torch
8
+ import pandas as pd
9
  import streamlit as st
10
 
11
 
 
88
 
89
  st.header('Financial News Sentiment')
90
  with st.spinner('finbert model getting sentiment...'):
91
+ positive, neutral, negative = get_news_sentiment(news)
92
+
93
+ # white: #D0D3D4
94
+ # red: #E74C3C
95
+ # green: #2ECC71
96
+ sentiment_df = pd.DataFrame(
97
+ {
98
+ 'sentiment_labels':['positive', 'neutral', 'negative'],
99
+ 'sentiment':[positive, neutral, negative],
100
+ 'color':['#2ECC71', '#D0D3D4', '#E74C3C']
101
+ }
102
+ )
103
+ st.bar_chart(sentiment_df, x='sentiment_labels', y='sentiment', color='color', horizontal=True)
104
 
105
  st.header('Financial News Summary')
106
  with st.spinner('facebook bart model is summarizing the news...'):
requirements.txt CHANGED
@@ -7,6 +7,7 @@ fsspec==2024.10.0
7
  huggingface-hub==0.26.2
8
  idna==3.10
9
  numpy==2.1.3
 
10
  packaging==24.2
11
  pipreqs==0.4.13
12
  PyYAML==6.0.2
 
7
  huggingface-hub==0.26.2
8
  idna==3.10
9
  numpy==2.1.3
10
+ pandas
11
  packaging==24.2
12
  pipreqs==0.4.13
13
  PyYAML==6.0.2