NazmusAshrafi commited on
Commit
c303720
1 Parent(s): 6e011da
Files changed (1) hide show
  1. app.py +28 -5
app.py CHANGED
@@ -2,11 +2,11 @@ import streamlit as st
2
  from transformers import pipeline, AutoModelForSequenceClassification, AutoTokenizer
3
 
4
 
5
- @st.cache(allow_output_mutation=True)
6
  def get_model():
7
  tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased")
8
  pulled_model = AutoModelForSequenceClassification.from_pretrained(
9
- "NazmusAshrafi/stock_twitter_sentiment_Bert")
10
  return tokenizer, pulled_model
11
 
12
 
@@ -19,13 +19,36 @@ classifier = pipeline("sentiment-analysis",
19
 
20
  # print(classifier("AAP Up Theory = Will go up in future, buy now"))
21
 
22
- st.title("Topic Modeling and Sentiment Analysis of Stock Tweets")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
  user_input = st.text_area("Enter a tweet about a stock")
25
  button = st.button("Analyze")
26
 
 
 
27
 
28
  if user_input and button:
29
  # output
30
- classifier("AAP Up Theory = Will go up in future, buy now")
31
- st.write("Raw Pred: ", classifier(user_input))
 
 
 
 
 
2
  from transformers import pipeline, AutoModelForSequenceClassification, AutoTokenizer
3
 
4
 
5
+ # @st.cache(allow_output_mutation=True)
6
  def get_model():
7
  tokenizer = AutoTokenizer.from_pretrained("distilbert-base-uncased")
8
  pulled_model = AutoModelForSequenceClassification.from_pretrained(
9
+ "NazmusAshrafi/stock_twitter_topic_Bert")
10
  return tokenizer, pulled_model
11
 
12
 
 
19
 
20
  # print(classifier("AAP Up Theory = Will go up in future, buy now"))
21
 
22
+ st.title("Find the topic of a stock related tweets")
23
+ st.subheader(
24
+ 'This model can predict 3 topics - :blue[Investment decision], :green[User Volume], :orange[Market crisis] - Entering a topic related tweet will yeild the best results')
25
+
26
+
27
+ st.markdown(
28
+ ':blue[Investment decision example: "AAP Dow Theory = Will go down in future, Do not buy"]')
29
+ st.markdown(
30
+ ':green[User Volume example: "Loosing a lot of volume, user are leaving this platform"]')
31
+ st.markdown(
32
+ ':orange[Market crisis example: "Market is in danger because of corona virus"]')
33
+
34
+
35
+ st.subheader("", divider='rainbow')
36
+ # 0 = Investment decision
37
+ # 1 = User volume
38
+ # 2 = Market crisis
39
+
40
 
41
  user_input = st.text_area("Enter a tweet about a stock")
42
  button = st.button("Analyze")
43
 
44
+ # print(classifier("AAP Down Theory = Will go down in future,do not buy now"))
45
+
46
 
47
  if user_input and button:
48
  # output
49
+ st.write("Topic Prediction: ", classifier(user_input)[0]['label'])
50
+ st.write("Confidence Score: ", classifier(user_input)[0]['score'])
51
+
52
+
53
+ st.markdown(
54
+ 'Note: Model may be predicting "Investment decision" way too often, this is because of the data imbalance. The model was trained on 3 topics, but the data was not balanced. The model was trained on a dataset where a large portion of the data was on "Investment decision" topic. This is why the model is biased towards "Investment decision" topic. This is a flaw of this model, and it can be fixed by training the model on a balanced dataset.')