azizbarank commited on
Commit
5424223
·
1 Parent(s): a872a6b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -9
app.py CHANGED
@@ -2,7 +2,7 @@
2
  """
3
  Created on Mon Jun 6 20:56:08 2022
4
 
5
- @author: User
6
  """
7
  import os
8
  os.system('pip install nltk')
@@ -15,19 +15,18 @@ nltk.download('stopwords')
15
  nltk.download('wordnet')
16
  nltk.download('omw-1.4')
17
 
18
- # importing relevant python packages
19
  import streamlit as st
20
  import joblib
21
- # preprocessing
22
  import re
23
  import string
24
  import nltk
25
  from nltk.corpus import stopwords
26
  from nltk.stem import WordNetLemmatizer
27
  from sklearn.feature_extraction.text import TfidfVectorizer
28
- # modeling
29
 
30
- # creating page sections
 
31
  site_header = st.container()
32
  business_context = st.container()
33
  data_desc = st.container()
@@ -44,8 +43,7 @@ with site_header:
44
  with tweet_input:
45
  st.header('Is Your Text Considered Toxic?')
46
  st.write("""*Please note that this prediction is based on how the model was trained, so it may not be an accurate representation.*""")
47
- # user input here
48
- user_text = st.text_input('Enter Text', max_chars=280) # setting input as user_text
49
 
50
  with model_results:
51
  st.subheader('Prediction:')
@@ -64,7 +62,7 @@ with model_results:
64
  for word in stopwords_removed:
65
  lemmatized_output.append(lemmatizer.lemmatize(word))
66
 
67
- # instantiating count vectorizor
68
  tfidf = TfidfVectorizer(stop_words= stop_words, ngram_range=(1,2))
69
  X_train = joblib.load(open('resources/X_train.pickel', 'rb'))
70
  X_test = lemmatized_output
@@ -74,7 +72,7 @@ with model_results:
74
  # loading in model
75
  final_model = joblib.load(open('resources/final_bayes.pickel', 'rb'))
76
 
77
- # apply model to make predictions
78
  prediction = final_model.predict(X_test_count[0])
79
 
80
  if prediction == 0:
 
2
  """
3
  Created on Mon Jun 6 20:56:08 2022
4
 
5
+ @author: Aziz Baran Kurtuluş
6
  """
7
  import os
8
  os.system('pip install nltk')
 
15
  nltk.download('wordnet')
16
  nltk.download('omw-1.4')
17
 
18
+
19
  import streamlit as st
20
  import joblib
 
21
  import re
22
  import string
23
  import nltk
24
  from nltk.corpus import stopwords
25
  from nltk.stem import WordNetLemmatizer
26
  from sklearn.feature_extraction.text import TfidfVectorizer
 
27
 
28
+
29
+
30
  site_header = st.container()
31
  business_context = st.container()
32
  data_desc = st.container()
 
43
  with tweet_input:
44
  st.header('Is Your Text Considered Toxic?')
45
  st.write("""*Please note that this prediction is based on how the model was trained, so it may not be an accurate representation.*""")
46
+ user_text = st.text_input('Enter Text', max_chars=280)
 
47
 
48
  with model_results:
49
  st.subheader('Prediction:')
 
62
  for word in stopwords_removed:
63
  lemmatized_output.append(lemmatizer.lemmatize(word))
64
 
65
+ # instantiating tfidf vectorizor
66
  tfidf = TfidfVectorizer(stop_words= stop_words, ngram_range=(1,2))
67
  X_train = joblib.load(open('resources/X_train.pickel', 'rb'))
68
  X_test = lemmatized_output
 
72
  # loading in model
73
  final_model = joblib.load(open('resources/final_bayes.pickel', 'rb'))
74
 
75
+ # applying the model to make predictions
76
  prediction = final_model.predict(X_test_count[0])
77
 
78
  if prediction == 0: