File size: 1,549 Bytes
14cd217
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
31
32
33
34
35
36
37
38
39
40
41
import skops.io as sio
import gradio as gr

pipe = sio.load("bank_marketing_pipe.skops", trusted=True)

classes = [
    "Not Subscribe",
    "Subscribe"]


def classifier(age, job, marital, education, default, balance, housing,loan, contact):
    pred = pipe.predict([[age, job, marital, education, default, balance, housing,loan, contact]])[0]
    label = f"Predicted output: **{classes[pred]}**"
    return label


inputs = [
    gr.Slider(10, 90, step=1, label="Age"),
    gr.Dropdown(["admin.","unknown","unemployed","management","housemaid","entrepreneur","student","blue-collar",
                 "self-employed","retired","technician","services"], label="Job", multiselect=False),
    gr.Dropdown(["married","divorced","single"], label="Marital", multiselect=False),
    gr.Dropdown(["unknown","secondary","primary","tertiary"], label="Education", multiselect=False),
    gr.Radio(["yes","no"], label="Default", info='has credit in default?'),
    gr.Slider(-100000, 100000, step=1, label="Balance"),
    gr.Radio(["yes","no"], label="Housing", info='has housing loan?'),
    gr.Radio(["yes","no"], label="Loan", info='has personal loan?'),
    gr.Dropdown(["unknown","telephone","cellular"], label="Contact")
]

outputs = [gr.Label(num_top_classes=2)]

title = "Deposit Subscription Prediction"
description = "Enter the details to identify where or not the customer is subscribed or not subscribed for deposit"

gr.Interface(
    fn=classifier,
    inputs=inputs,
    outputs=outputs,
    title=title,
    description=description,
).launch()