File size: 869 Bytes
925e416
 
 
cbd3f4c
925e416
 
 
 
 
 
 
 
 
 
e5d6638
7129d6d
925e416
 
 
17ac362
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
# 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=[
                            'This is a text about healthcare', 'This is a text about technology', 'This is a text about other'],
                        allow_flagging='never'
                        )