aaronbi/lab06
0
1import gradio as gr2from joblib import dump, load3 4model_names = ['Logistic_Regression', 'LDA', 'QDA', 'Naive_Bayes', 'SVC']5models = {}6 7vectorizer = load('vectorizer.joblib')8 9for name in model_names:10 models[name] = load(name + '.joblib')11 12 13def 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 21input_module1 = gr.Textbox(label='Review Comment')22input_module2 = gr.Dropdown(choices=model_names, label = "method")23 24output_module = gr.Label(num_top_classes=2,label = "Predicted Probabilities")25 26gr.Interface(fn=predict, inputs=[input_module1,input_module2], outputs=output_module).launch(debug=True)