File size: 3,411 Bytes
63e0ec1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8c8d566
e4e50f7
 
63e0ec1
e4e50f7
 
 
 
 
 
 
 
 
 
 
63e0ec1
e4e50f7
 
 
 
 
 
 
 
 
 
63e0ec1
e4e50f7
 
 
675c1ea
e4e50f7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import streamlit as st
import pandas as pd
from huggingface_hub import hf_hub_download
import joblib

# Download and load the trained model
model_path = hf_hub_download(repo_id="lcsekar/tourism-project-model", filename="best_model_v1.joblib")
model = joblib.load(model_path)

# Streamlit UI
st.title("Visit with Us - Purchase Prediction App")
st.write("""
This application predicts whether the user will buy a tourism package from Visit with Us
based on user details such as age, occupation, gender, marital status and income.
Please enter the app details below to get the prediction.
""")

# User input
# create two columns for better layout
col1, col2 = st.columns(2)

with col1:
    customer_id = st.number_input("Customer ID", min_value=1)
    age = st.number_input("Age", min_value=18, max_value=100, value=30)
    type_of_contact = st.selectbox("Type of Contact", ["Self Enquiry", "Company Invited"])
    city_tier = st.selectbox("City Tier", [1, 2, 3])
    occupation = st.selectbox("Occupation", ["Salaried", "Free Lancer", "Small Business", "Large Business"])
    gender = st.selectbox("Gender", ["Male", "Female"])
    num_person_visiting = st.number_input("Number of Persons Visiting", min_value=1, max_value=20, value=2)
    preferred_property_star = st.selectbox("Preferred Property Star", [3, 4, 5])
    marital_status = st.selectbox("Marital Status", ["Single", "Divorced", "Married", "Unmarried"])
    num_trips = st.number_input("Number of Trips", min_value=0, max_value=50, value=5)

with col2:
    passport = st.selectbox("Passport", ["Yes", "No"])
    own_car = st.selectbox("Own Car", ["Yes", "No"])
    num_children_visiting = st.number_input("Number of Children Visiting", min_value=0, max_value=10, value=0)
    designation = st.selectbox("Designation", ["Executive", "Manager", "Senior Manager", "AVP", "VP"])
    monthly_income = st.number_input("Monthly Income (USD)", min_value=1000, max_value=100000, value=5000)
    pitch_satisfaction_score = st.selectbox("Pitch Satisfaction Score", [1, 2, 3, 4, 5])
    product_pitched = st.selectbox("Product Pitched", ["Super Deluxe", "Deluxe", "Standard", "Basic", "King"])
    num_followups = st.number_input("Number of Followups", min_value=0, max_value=20, value=2)
    duration_of_pitch = st.number_input("Duration of Pitch (minutes)", min_value=1, max_value=120, value=30)

# Assemble input into DataFrame
input_data = pd.DataFrame([{
    'Age': age,
    'TypeofContact': type_of_contact,
    'CityTier': city_tier,
    'Occupation': occupation,
    'Gender': gender,
    'NumberOfPersonVisiting': num_person_visiting,
    'PreferredPropertyStar': preferred_property_star,
    'MaritalStatus': marital_status,
    'NumberOfTrips': num_trips,
    'Passport': 1 if passport == "Yes" else 0,
    'OwnCar': 1 if own_car == "Yes" else 0,
    'NumberOfChildrenVisiting': num_children_visiting,
    'Designation': designation,
    'MonthlyIncome': monthly_income,
    'PitchSatisfactionScore': pitch_satisfaction_score,
    'ProductPitched': product_pitched,
    'NumberOfFollowups': num_followups,
    'DurationOfPitch': duration_of_pitch
}])
print(input_data)

# Predict button
if st.button("Predict"):
    prediction = model.predict(input_data)[0]
    print(f"Prediction: {prediction}")
    st.subheader("Prediction Result:")
    st.success(f"The customer is {'likely' if prediction == 1 else 'not likely'} to purchase the tourism package.")