Jeffrey Rathgeber Jr commited on
Commit
8e88f49
·
unverified ·
1 Parent(s): 39aeda0
Files changed (1) hide show
  1. app.py +21 -19
app.py CHANGED
@@ -14,14 +14,16 @@ while True:
14
  st.write('You selected:', option)
15
 
16
  if option == 'MILESTONE 3: FINE-TUNED':
17
-
18
- model_name = "distilbert-base-uncased-finetuned-sst-2-english"
19
- model = AutoModelForSequenceClassification.from_pretrained(model_name)
20
- tokenizer = AutoTokenizer.from_pretrained(model_name)
21
- classifier = pipeline(task="sentiment-analysis", model=model, tokenizer=tokenizer)
22
- preds = classifier(textIn)
23
- preds = [{"score": round(pred["score"], 4), "label": pred["label"]} for pred in preds]
24
- st.write('According to Pipeline, input text is ', preds[0]['label'], ' with a confidence of ', preds[0]['score'])
 
 
25
 
26
  # model_name_0 = "Rathgeberj/milestone3_0"
27
  # model_0 = AutoModelForSequenceClassification.from_pretrained(model_name_0)
@@ -73,17 +75,17 @@ while True:
73
  preds = [{"score": round(pred["score"], 4), "label": pred["label"]} for pred in preds]
74
  st.write('According to Pipeline, input text is ', preds[0]['label'], ' with a confidence of ', preds[0]['score'])
75
 
76
- if option == 'TextBlob':
77
- polarity = TextBlob(textIn).sentiment.polarity
78
- subjectivity = TextBlob(textIn).sentiment.subjectivity
79
- sentiment = ''
80
- if polarity < 0:
81
- sentiment = 'Negative'
82
- elif polarity == 0:
83
- sentiment = 'Neutral'
84
- else:
85
- sentiment = 'Positive'
86
- st.write('According to TextBlob, input text is ', sentiment, ' and a subjectivity score (from 0 being objective to 1 being subjective) of ', subjectivity)
87
 
88
 
89
  #------------------------------------------------------------------------
 
14
  st.write('You selected:', option)
15
 
16
  if option == 'MILESTONE 3: FINE-TUNED':
17
+ polarity = TextBlob(textIn).sentiment.polarity
18
+ subjectivity = TextBlob(textIn).sentiment.subjectivity
19
+ sentiment = ''
20
+ if polarity < 0:
21
+ sentiment = 'Negative'
22
+ elif polarity == 0:
23
+ sentiment = 'Neutral'
24
+ else:
25
+ sentiment = 'Positive'
26
+ st.write('According to TextBlob, input text is ', sentiment, ' and a subjectivity score (from 0 being objective to 1 being subjective) of ', subjectivity)
27
 
28
  # model_name_0 = "Rathgeberj/milestone3_0"
29
  # model_0 = AutoModelForSequenceClassification.from_pretrained(model_name_0)
 
75
  preds = [{"score": round(pred["score"], 4), "label": pred["label"]} for pred in preds]
76
  st.write('According to Pipeline, input text is ', preds[0]['label'], ' with a confidence of ', preds[0]['score'])
77
 
78
+ # if option == 'TextBlob':
79
+ # polarity = TextBlob(textIn).sentiment.polarity
80
+ # subjectivity = TextBlob(textIn).sentiment.subjectivity
81
+ # sentiment = ''
82
+ # if polarity < 0:
83
+ # sentiment = 'Negative'
84
+ # elif polarity == 0:
85
+ # sentiment = 'Neutral'
86
+ # else:
87
+ # sentiment = 'Positive'
88
+ # st.write('According to TextBlob, input text is ', sentiment, ' and a subjectivity score (from 0 being objective to 1 being subjective) of ', subjectivity)
89
 
90
 
91
  #------------------------------------------------------------------------