stanlys96 commited on
Commit
21a9c98
·
verified ·
1 Parent(s): 0281523

Upload 6 files

Browse files
Files changed (2) hide show
  1. eda.py +2 -0
  2. prediction.py +18 -17
eda.py CHANGED
@@ -2,6 +2,8 @@ import streamlit as st
2
  import pandas as pd
3
  import matplotlib.pyplot as plt
4
  import seaborn as sns
 
 
5
  from nltk.corpus import stopwords
6
  from wordcloud import WordCloud
7
 
 
2
  import pandas as pd
3
  import matplotlib.pyplot as plt
4
  import seaborn as sns
5
+ import nltk
6
+ nltk.download('stopwords')
7
  from nltk.corpus import stopwords
8
  from wordcloud import WordCloud
9
 
prediction.py CHANGED
@@ -17,25 +17,26 @@ def get_feeling(number):
17
  feeling = number_to_feeling.get(str(number), "Unknown feeling")
18
  return feeling
19
 
 
 
 
20
  def app():
21
  st.header('Prediction', divider='rainbow')
22
 
23
  user_input = st.text_input("Enter your text here:")
24
- with st.spinner("Loading the model, please wait..."):
25
- the_model = tf.keras.models.load_model('model.keras', custom_objects={'KerasLayer': tf_hub.KerasLayer})
26
- if st.button('Predict', type="secondary"):
27
- data = {
28
- "text_processed": [
29
- user_input
30
- ]
31
- }
32
- df = pd.DataFrame(data)
33
- with st.spinner("Making prediction..."):
34
- # Replace with your preprocessing and prediction code
35
- predictions = the_model.predict(df)
36
- predicted_class = np.argmax(predictions, axis=1)
37
- the_sentiment = predicted_class[0]
38
 
39
- st.write(f"We have predicted that the sentiment of this text is {get_feeling(the_sentiment)}")
40
- else:
41
- st.write("Click the button to predict!")
 
17
  feeling = number_to_feeling.get(str(number), "Unknown feeling")
18
  return feeling
19
 
20
+ with st.spinner("Loading the model, please wait..."):
21
+ the_model = tf.keras.models.load_model('model.keras', custom_objects={'KerasLayer': tf_hub.KerasLayer})
22
+
23
  def app():
24
  st.header('Prediction', divider='rainbow')
25
 
26
  user_input = st.text_input("Enter your text here:")
27
+ if st.button('Predict', type="secondary"):
28
+ data = {
29
+ "text_processed": [
30
+ user_input
31
+ ]
32
+ }
33
+ df = pd.DataFrame(data)
34
+ with st.spinner("Making prediction..."):
35
+ # Replace with your preprocessing and prediction code
36
+ predictions = the_model.predict(df)
37
+ predicted_class = np.argmax(predictions, axis=1)
38
+ the_sentiment = predicted_class[0]
 
 
39
 
40
+ st.write(f"We have predicted that the sentiment of this text is {get_feeling(the_sentiment)}")
41
+ else:
42
+ st.write("Click the button to predict!")