Pratik26Dec's picture
Upload folder using huggingface_hub
8e97f5e verified
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)