Amitgupta2982 commited on
Commit
96c7e98
·
verified ·
1 Parent(s): 2b20dc6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +71 -3
app.py CHANGED
@@ -1,7 +1,75 @@
1
  import streamlit as st
 
 
 
2
 
3
- st.title("Tourism Package Prediction App ")
 
 
 
 
 
 
 
4
 
5
- st.write("Your Streamlit Space is running successfully!")
 
 
 
6
 
7
- st.success("Model + Pipeline integrated ")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
+ import pandas as pd
3
+ from huggingface_hub import hf_hub_download
4
+ import joblib
5
 
6
+ # -------------------------------------------------------
7
+ # DOWNLOAD AND LOAD THE TOURISM MODEL FROM HUGGINGFACE
8
+ # -------------------------------------------------------
9
+ model_path = hf_hub_download(
10
+ repo_id="Amitgupta2982/Tourism-Package-Model",
11
+ filename="tourism_xgb_best_model_v1.joblib"
12
+ )
13
+ model = joblib.load(model_path)
14
 
15
+ # -------------------------------------------------------
16
+ # STREAMLIT USER INTERFACE
17
+ # -------------------------------------------------------
18
+ st.title("Tourism Package Purchase Prediction App")
19
 
20
+ st.write("""
21
+ This interactive application predicts whether a customer is likely to purchase a tourism package.
22
+
23
+ Please enter the customer's demographic, income, and interaction details below to generate the prediction.
24
+ """)
25
+
26
+ # -------------------------------------------------------
27
+ # USER INPUT FIELDS
28
+ # -------------------------------------------------------
29
+ Age = st.number_input("Age", min_value=18, max_value=80, value=35)
30
+ CityTier = st.selectbox("City Tier", [1, 2, 3])
31
+ DurationOfPitch = st.number_input("Duration of Pitch (Minutes)", min_value=0, max_value=50, value=10)
32
+ Gender = st.selectbox("Gender", ["Male", "Female"])
33
+ NumberOfPersonVisiting = st.number_input("Number of People Visiting", min_value=1, max_value=10, value=2)
34
+ NumberOfFollowups = st.number_input("Number of Follow-ups", min_value=0, max_value=10, value=1)
35
+ PreferredPropertyStar = st.selectbox("Preferred Hotel Star Rating", [3, 4, 5])
36
+ MaritalStatus = st.selectbox("Marital Status", ["Single", "Married", "Divorced"])
37
+ Passport = st.selectbox("Passport Available?", [0, 1])
38
+ PitchSatisfactionScore = st.slider("Pitch Satisfaction Score", 1, 5, 3)
39
+ OwnCar = st.selectbox("Own Car?", [0, 1])
40
+ NumberOfChildrenVisiting = st.number_input("Number of Children Visiting", min_value=0, max_value=5, value=0)
41
+ Designation = st.selectbox(
42
+ "Customer Designation",
43
+ ["Executive", "Manager", "Senior Manager", "AVP", "VP"]
44
+ )
45
+ MonthlyIncome = st.number_input("Monthly Income (in local currency)", min_value=3000, max_value=300000, value=50000)
46
+
47
+ # -------------------------------------------------------
48
+ # ASSEMBLE INPUT FOR THE MODEL
49
+ # -------------------------------------------------------
50
+ input_data = pd.DataFrame([{
51
+ "Age": Age,
52
+ "CityTier": CityTier,
53
+ "DurationOfPitch": DurationOfPitch,
54
+ "Gender": Gender,
55
+ "NumberOfPersonVisiting": NumberOfPersonVisiting,
56
+ "NumberOfFollowups": NumberOfFollowups,
57
+ "PreferredPropertyStar": PreferredPropertyStar,
58
+ "MaritalStatus": MaritalStatus,
59
+ "Passport": Passport,
60
+ "PitchSatisfactionScore": PitchSatisfactionScore,
61
+ "OwnCar": OwnCar,
62
+ "NumberOfChildrenVisiting": NumberOfChildrenVisiting,
63
+ "Designation": Designation,
64
+ "MonthlyIncome": MonthlyIncome
65
+ }])
66
+
67
+ # -------------------------------------------------------
68
+ # PREDICTION BUTTON
69
+ # -------------------------------------------------------
70
+ if st.button("Predict Tourism Package Purchase"):
71
+ prediction = model.predict(input_data)[0]
72
+ result = "LIKELY to Purchase" if prediction == 1 else "NOT Likely to Purchase"
73
+
74
+ st.subheader("Prediction Result:")
75
+ st.success(f"The model predicts: **{result}**")