File size: 1,803 Bytes
8e97f5e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
42
43
44
45
46
47
48
49
50

import gradio as gr
from inference import predict

feature_inputs = [
    gr.Number(label="Age"),
    gr.Dropdown(["Self Enquiry", "Company Invited"], label="TypeofContact"),
    gr.Number(label="CityTier"),
    gr.Number(label="DurationOfPitch"),
    gr.Dropdown(["Salaried", "Business", "Free Lancer"], label="Occupation"),
    gr.Dropdown(["Male", "Female"], label="Gender"),
    gr.Number(label="NumberOfPersonVisiting"),
    gr.Number(label="NumberOfFollowups"),
    gr.Dropdown(["Basic", "Deluxe", "Super Deluxe", "King", "Queen"], label="ProductPitched"),
    gr.Number(label="PreferredPropertyStar"),
    gr.Dropdown(["Single", "Married"], label="MaritalStatus"),
    gr.Number(label="NumberOfTrips"),
    gr.Dropdown([0,1], label="Passport"),
    gr.Number(label="PitchSatisfactionScore"),
    gr.Dropdown([0,1], label="OwnCar"),
    gr.Number(label="NumberOfChildrenVisiting"),
    gr.Dropdown(["Executive","Manager","Senior Manager"], label="Designation"),
    gr.Number(label="MonthlyIncome"),
]

def predict_from_ui(*vals):
    cols = [
        "Age","TypeofContact","CityTier","DurationOfPitch",
        "Occupation","Gender","NumberOfPersonVisiting",
        "NumberOfFollowups","ProductPitched","PreferredPropertyStar",
        "MaritalStatus","NumberOfTrips","Passport",
        "PitchSatisfactionScore","OwnCar","NumberOfChildrenVisiting",
        "Designation","MonthlyIncome"
    ]

    data = {col: val for col, val in zip(cols, vals)}
    output = predict(data)

    return "Customer Will Buy" if output == 1 else "Customer Will Not Buy"

app = gr.Interface(
    fn=predict_from_ui,
    inputs=feature_inputs,
    outputs=gr.Textbox(label="Prediction"),
    title="Tourism Package Prediction",
)

if __name__ == "__main__":
    app.launch(server_name="0.0.0.0", server_port=7860)