File size: 906 Bytes
925e416
 
 
cbd3f4c
925e416
2aa7ddb
 
 
925e416
2aa7ddb
925e416
2aa7ddb
925e416
2aa7ddb
 
925e416
 
733f064
7862c87
 
 
8b60d18
925e416
c71ee2b
 
733f064
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
28
29
30
# Imports
import gradio as gr
from sklearn.linear_model import LogisticRegression
import pickle5 as pickle

# file name
lr_filename = 'lg_classifier.sav'

# Load model from pickle file
model = pickle.load(open(lr_filename, 'rb'))

# Define function to make a prediction with the model
def predict(text):
    return model.predict([text])[0]


# Define interface
demo = 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: Other: 1, Healthcare: 2, Technology: 3", lines=2, placeholder='Predicted label will appear here...'),
                        allow_flagging='never'
)

demo.launch()