aaronbi commited on
Commit
8c88c2f
1 Parent(s): 8bdcf9c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from joblib import dump, load
3
+
4
+ model_names = ['Logistic_Regression', 'LDA', 'QDA', 'Naive_Bayes', 'SVC']
5
+ models = {}
6
+
7
+ vectorizer = load('vectorizer.joblib')
8
+
9
+ for name in model_names:
10
+ models[name] = load(name + '.joblib')
11
+
12
+
13
+ def predict(text, method):
14
+
15
+ prediction = models[method].predict_proba(vectorizer.transform([text]).toarray())[0]
16
+
17
+
18
+ return {'Negative Comment':prediction[0], 'Positive Comment':prediction[1]}
19
+
20
+
21
+ input_module1 = gr.Textbox(label='Review Comment')
22
+ input_module2 = gr.Dropdown(choices=model_names, label = "method")
23
+
24
+ output_module = gr.Label(num_top_classes=2,label = "Predicted Probabilities")
25
+
26
+ gr.Interface(fn=predict, inputs=[input_module1,input_module2], outputs=output_module).launch(debug=True)