mle10-glg-demo / app.py
curtpond's picture
More updates to app.py
bf0ed33
raw
history blame
1.13 kB
# Imports
import gradio as gr
from sklearn.linear_model import LogisticRegression
import pickle5 as pickle
# Load model from pickle file
model = pickle.load(open('lg_classifier.sav', 'rb'))
# Define function to predict
def predict(text):
return model.predict([text])[0]
# Define interface
iface = gr.Interface(fn=predict,
inputs=gr.inputs.Textbox(lines=10, label="Input Text"),
outputs=gr.outputs.Label(num_top_classes=3),
title="Text Classification",
description="Classify text as other[0], healthcare[1], or technology[2]",
examples=['The indictments were announced Tuesday by the Justice Department in Cairo.', "In 2019, the men's singles winner was Novak Djokovic who defeated Roger Federer in a tournament taking place in the United Kingdom.", 'In a study published by the American Heart Association on January 18, researchers at the Johns Hopkins School of Medicine found that meal timing did not impact weight.'],
allow_flagging='never'
)
demo = iface.launch(share=True)