Visit-With-Us / src /streamlit_app.py
VeerendraManikonda's picture
Update src/streamlit_app.py
30c506b verified
import streamlit as st
import pandas as pd
from huggingface_hub import hf_hub_download
import joblib
# Download and load the model
model_path = hf_hub_download(repo_id="VeerendraManikonda/visit_with_us_model", filename="best_tourism_model_v1.joblib")
model = joblib.load(model_path)
# Streamlit UI for Machine Failure Prediction
st.title("Tourism Prediction App")
st.write("""
This application predicts the potential buyers of the products based on the pitch parameters.
Please enter the customer interaction details.
""")
# Input form
with st.form("prediction_form"):
Age = st.number_input("Age", min_value=18, max_value=100, value=30)
TypeofContact = st.selectbox("Type of Contact", ["Self Enquiry", "Company Invited"])
CityTier = st.selectbox("City Tier", [1, 2, 3])
DurationOfPitch = st.number_input("Duration Of Pitch", min_value=0, max_value=50, value=10)
Occupation = st.selectbox("Occupation", ["Salaried", "Small Business", "Large Business", "Student", "Free Lancer"])
Gender = st.selectbox("Gender", ["Male", "Female"])
NumberOfPersonVisiting = st.number_input("Number Of Persons Visiting", min_value=1, max_value=10, value=1)
NumberOfFollowups = st.number_input("Number Of Follow-ups", min_value=0, max_value=20, value=1)
ProductPitched = st.selectbox("Product Pitched", ["Basic", "Standard", "Deluxe"])
PreferredPropertyStar = st.selectbox("Preferred Property Star", [1, 2, 3, 4, 5])
MaritalStatus = st.selectbox("Marital Status", ["Single", "Married", "Divorced"])
NumberOfTrips = st.number_input("Number Of Trips", min_value=0, max_value=100, value=1)
Passport = st.selectbox("Passport", [0, 1])
PitchSatisfactionScore = st.slider("Pitch Satisfaction Score", 1, 5, 3)
OwnCar = st.selectbox("Own Car", [0, 1])
NumberOfChildrenVisiting = st.number_input("Number Of Children Visiting", min_value=0, max_value=10, value=0)
Designation = st.selectbox("Designation", ["Manager", "Senior Manager", "Executive", "AVP"])
MonthlyIncome = st.number_input("Monthly Income", min_value=1000, max_value=100000, value=25000)
submit = st.form_submit_button("Predict")
if submit:
# Convert inputs to DataFrame
input_data = pd.DataFrame([{
"Age": Age,
"TypeofContact": TypeofContact,
"CityTier": CityTier,
"DurationOfPitch": DurationOfPitch,
"Occupation": Occupation,
"Gender": Gender,
"NumberOfPersonVisiting": NumberOfPersonVisiting,
"NumberOfFollowups": NumberOfFollowups,
"ProductPitched": ProductPitched,
"PreferredPropertyStar": PreferredPropertyStar,
"MaritalStatus": MaritalStatus,
"NumberOfTrips": NumberOfTrips,
"Passport": Passport,
"PitchSatisfactionScore": PitchSatisfactionScore,
"OwnCar": OwnCar,
"NumberOfChildrenVisiting": NumberOfChildrenVisiting,
"Designation": Designation,
"MonthlyIncome": MonthlyIncome
}])
# Predict
prediction = model.predict(input_data)[0]
if prediction == 1:
st.success("Customer is likely to purchase the product.")
else:
st.error("Customer is not likely to purchase the product.")