georgeek commited on
Commit
154771f
Β·
1 Parent(s): ba54225
Files changed (1) hide show
  1. pages/8_Models.py +21 -3
pages/8_Models.py CHANGED
@@ -22,10 +22,28 @@ def run():
22
  model = LogisticRegression()
23
  # (Insert a sample dataset and training procedure here)
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  # Deep Learning Example: Using Pretrained Transformers
26
- st.write("### Example: Transformer Model")
27
- nlp = pipeline("sentiment-analysis")
28
- st.write(nlp("I love machine learning!"))
29
 
30
  st.write("## Quiz: Conceptual Questions")
31
  q1 = st.radio("What is a transformer model used for?", ["Text classification", "Image processing", "Time series analysis"])
 
22
  model = LogisticRegression()
23
  # (Insert a sample dataset and training procedure here)
24
 
25
+
26
+ # Deep Learning Example: Using Pretrained Transformers
27
+ st.write("### Example: Transformer Model for Sentiment Analysis")
28
+
29
+ # Initialize the NLP pipeline for sentiment analysis
30
+ nlp_pipeline = pipeline("sentiment-analysis")
31
+
32
+ def analyze_sentiment(user_sentence):
33
+ response = nlp_pipeline(user_sentence)
34
+ return response[0]
35
+
36
+ # Example usage
37
+ user_sentence = st.text_input("Enter a sentence for sentiment analysis:")
38
+ if user_sentence:
39
+ response = analyze_sentiment(user_sentence)
40
+ st.write(f"Sentiment: {response['label']}, Score: {response['score']}")
41
+
42
+
43
  # Deep Learning Example: Using Pretrained Transformers
44
+ #st.write("### Example: Transformer Model")
45
+ #nlp = pipeline("sentiment-analysis")
46
+ #st.write(nlp("I love machine learning!"))
47
 
48
  st.write("## Quiz: Conceptual Questions")
49
  q1 = st.radio("What is a transformer model used for?", ["Text classification", "Image processing", "Time series analysis"])