Spaces:
Runtime error
Runtime error
Upload 5 files
Browse files- app.py +21 -0
- model.pkl +3 -0
- preprocessing.py +25 -0
- requirements.txt +0 -0
- vectorizer.pkl +3 -0
app.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from preprocessing import vectorizer
|
3 |
+
|
4 |
+
|
5 |
+
def predict_category(Issue, SubIssue):
|
6 |
+
model, vectorize, category_mapping = vectorizer()
|
7 |
+
example_text = Issue + " " + SubIssue
|
8 |
+
example_text_vecorized = vectorize.transform([example_text])
|
9 |
+
predicted_category = model.predict(example_text_vecorized)
|
10 |
+
predicted_category_name = [category for category,index in category_mapping.items() if index == predicted_category[0]][0]
|
11 |
+
return predicted_category_name
|
12 |
+
|
13 |
+
gr.Interface(title="Predict the category",
|
14 |
+
description="Here we take issue and subissue of the user and predict different product categories",
|
15 |
+
fn=predict_category,
|
16 |
+
inputs = [gr.Textbox(lines=2,placeholder="Enter issue"),
|
17 |
+
gr.Textbox(lines=2,placeholder="Enter Subissue")],
|
18 |
+
allow_flagging="never",
|
19 |
+
outputs="text",
|
20 |
+
examples=[["i need money for my masters education","till now i haven't got it"],
|
21 |
+
["My money is debited from account and still now not transferred to respective bank account","It's been 3 hours"]]).launch()
|
model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:02313298f3d993cb4baa551d41cb699b2370e1c1e3c0a282cfcfc77e1f6c9d90
|
3 |
+
size 28146
|
preprocessing.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
import numpy as np
|
3 |
+
import pickle
|
4 |
+
import warnings
|
5 |
+
warnings.filterwarnings("ignore")
|
6 |
+
|
7 |
+
def vectorizer():
|
8 |
+
category_mapping = {'Debt collection': 0,
|
9 |
+
'Mortgage': 1,
|
10 |
+
'Consumer Loan': 2,
|
11 |
+
'Bank account or service': 3,
|
12 |
+
'Credit reporting': 4,
|
13 |
+
'Payday loan': 5,
|
14 |
+
'Other financial service': 6,
|
15 |
+
'Student loan': 7,
|
16 |
+
'Money transfers': 8,
|
17 |
+
'Prepaid card': 9,
|
18 |
+
'Credit card': 10
|
19 |
+
}
|
20 |
+
|
21 |
+
print("Created Mapping")
|
22 |
+
model = pickle.load(open("model.pkl",'rb'))
|
23 |
+
vectorizer = pickle.load(open("vectorizer.pkl",'rb'))
|
24 |
+
print("Loaded the model")
|
25 |
+
return model, vectorizer, category_mapping
|
requirements.txt
ADDED
Binary file (96 Bytes). View file
|
|
vectorizer.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9d35ad42bf1caaca6c282f237f7d683d35bedab2c41516083a90623de8cc9c73
|
3 |
+
size 9528
|