Spaces:
Runtime error
Runtime error
Commit
·
b47d6ba
1
Parent(s):
866e820
Upload app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,9 @@
|
|
1 |
-
#
|
2 |
-
|
3 |
-
|
4 |
|
|
|
|
|
5 |
import nltk
|
6 |
|
7 |
nltk.download('punkt')
|
@@ -11,11 +13,7 @@ nltk.download('omw-1.4')
|
|
11 |
|
12 |
# importing relevant python packages
|
13 |
import streamlit as st
|
14 |
-
import pandas as pd
|
15 |
-
import numpy as np
|
16 |
-
import pickle
|
17 |
import joblib
|
18 |
-
from PIL import Image
|
19 |
# preprocessing
|
20 |
import re
|
21 |
import string
|
@@ -24,9 +22,6 @@ from nltk.corpus import stopwords
|
|
24 |
from nltk.stem import WordNetLemmatizer
|
25 |
from sklearn.feature_extraction.text import TfidfVectorizer
|
26 |
# modeling
|
27 |
-
from sklearn import svm
|
28 |
-
# sentiment analysis
|
29 |
-
|
30 |
|
31 |
# creating page sections
|
32 |
site_header = st.container()
|
@@ -67,13 +62,13 @@ with model_results:
|
|
67 |
|
68 |
# instantiating count vectorizor
|
69 |
tfidf = TfidfVectorizer(stop_words=stop_words)
|
70 |
-
X_train = joblib.load(open('
|
71 |
X_test = lemmatized_output
|
72 |
X_train_count = tfidf.fit_transform(X_train)
|
73 |
X_test_count = tfidf.transform(X_test)
|
74 |
|
75 |
# loading in model
|
76 |
-
final_model = joblib.load(open('
|
77 |
|
78 |
# apply model to make predictions
|
79 |
prediction = final_model.predict(X_test_count[0])
|
@@ -82,4 +77,4 @@ with model_results:
|
|
82 |
st.subheader('**Not Hate Speech**')
|
83 |
else:
|
84 |
st.subheader('**Hate Speech**')
|
85 |
-
st.text('')
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
"""
|
3 |
+
Created on Mon Jun 6 20:56:08 2022
|
4 |
|
5 |
+
@author: User
|
6 |
+
"""
|
7 |
import nltk
|
8 |
|
9 |
nltk.download('punkt')
|
|
|
13 |
|
14 |
# importing relevant python packages
|
15 |
import streamlit as st
|
|
|
|
|
|
|
16 |
import joblib
|
|
|
17 |
# preprocessing
|
18 |
import re
|
19 |
import string
|
|
|
22 |
from nltk.stem import WordNetLemmatizer
|
23 |
from sklearn.feature_extraction.text import TfidfVectorizer
|
24 |
# modeling
|
|
|
|
|
|
|
25 |
|
26 |
# creating page sections
|
27 |
site_header = st.container()
|
|
|
62 |
|
63 |
# instantiating count vectorizor
|
64 |
tfidf = TfidfVectorizer(stop_words=stop_words)
|
65 |
+
X_train = joblib.load(open('X_train.pickel', 'rb'))
|
66 |
X_test = lemmatized_output
|
67 |
X_train_count = tfidf.fit_transform(X_train)
|
68 |
X_test_count = tfidf.transform(X_test)
|
69 |
|
70 |
# loading in model
|
71 |
+
final_model = joblib.load(open('final_bayes.pickle', 'rb'))
|
72 |
|
73 |
# apply model to make predictions
|
74 |
prediction = final_model.predict(X_test_count[0])
|
|
|
77 |
st.subheader('**Not Hate Speech**')
|
78 |
else:
|
79 |
st.subheader('**Hate Speech**')
|
80 |
+
st.text('')
|