lab06 / app.py
aaronbi's picture
Create app.py
8c88c2f
raw
history blame contribute delete
No virus
744 Bytes
import gradio as gr
from joblib import dump, load
model_names = ['Logistic_Regression', 'LDA', 'QDA', 'Naive_Bayes', 'SVC']
models = {}
vectorizer = load('vectorizer.joblib')
for name in model_names:
models[name] = load(name + '.joblib')
def predict(text, method):
prediction = models[method].predict_proba(vectorizer.transform([text]).toarray())[0]
return {'Negative Comment':prediction[0], 'Positive Comment':prediction[1]}
input_module1 = gr.Textbox(label='Review Comment')
input_module2 = gr.Dropdown(choices=model_names, label = "method")
output_module = gr.Label(num_top_classes=2,label = "Predicted Probabilities")
gr.Interface(fn=predict, inputs=[input_module1,input_module2], outputs=output_module).launch(debug=True)