Spaces:
Build error
Build error
Arun Prakash
commited on
Commit
·
48e70a5
1
Parent(s):
3cecf04
Add application file
Browse files- app.py +49 -0
- model.pickle +3 -0
- requirements.txt +1 -0
- tfidf.pickle +3 -0
app.py
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pickle
|
3 |
+
|
4 |
+
|
5 |
+
import numpy as np
|
6 |
+
import pandas as pd
|
7 |
+
import re
|
8 |
+
import string
|
9 |
+
import nltk
|
10 |
+
from sklearn.feature_extraction.text import TfidfVectorizer
|
11 |
+
from sklearn.ensemble import RandomForestClassifier
|
12 |
+
from sklearn.model_selection import train_test_split
|
13 |
+
from sklearn.metrics import confusion_matrix, classification_report
|
14 |
+
import matplotlib.pyplot as plt
|
15 |
+
from sklearn.metrics import plot_confusion_matrix
|
16 |
+
|
17 |
+
|
18 |
+
stopwords = nltk.corpus.stopwords.words('english')
|
19 |
+
|
20 |
+
def text_clean(text):
|
21 |
+
clean_words = []
|
22 |
+
|
23 |
+
word_L = text.split()
|
24 |
+
for w in word_L:
|
25 |
+
word_l = w.lower().strip()
|
26 |
+
if word_l.isalpha():
|
27 |
+
if len(word_l) > 3:
|
28 |
+
if word_l not in stopwords :
|
29 |
+
clean_words.append(word_l)
|
30 |
+
else:
|
31 |
+
continue
|
32 |
+
return clean_words
|
33 |
+
|
34 |
+
model = pickle.load(open("model.pickle", "rb"))
|
35 |
+
tfidf = pickle.load(open("tfidf.pickle","rb"))
|
36 |
+
|
37 |
+
|
38 |
+
st.header("NLP Consumer Complaints")
|
39 |
+
|
40 |
+
st.write("Please enter the complaint")
|
41 |
+
|
42 |
+
t = st.text_area("comp")
|
43 |
+
|
44 |
+
print(model.predict(tfidf.transform([t]).toarray()))
|
45 |
+
|
46 |
+
b = st.button("Submit")
|
47 |
+
|
48 |
+
if len(t) > 0 and b:
|
49 |
+
st.write(model.predict(tfidf.transform([t]).toarray())[0])
|
model.pickle
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7aed7645b2cdff9247d0227e6e75b5943bbf8393cd15e046d968d6ffd26d6e18
|
3 |
+
size 1731983
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
fastai
|
tfidf.pickle
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5f7c5cea3f05237f9156993e672aa8ece2d1fc4766eba4a0f80593843cf8511e
|
3 |
+
size 1610937
|