File size: 1,239 Bytes
925e416
 
 
cbd3f4c
925e416
 
 
 
 
 
 
 
 
 
7862c87
 
 
 
bf0ed33
925e416
c71ee2b
 
 
925e416
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# 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,
                        title="Text Classification Demo",
                        description="This is a demo of a text classification model using Logistic Regression.",
                        inputs=gr.Textbox(lines=10, placeholder='Input text here...', label="Input Text"),
                        outputs=gr.Textbox(label="Predicted Label", lines=2, placeholder='Predicted label will appear here...'),
                        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)