roshra commited on
Commit
70ccb92
·
verified ·
1 Parent(s): 7aa2f76

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +34 -46
app.py CHANGED
@@ -1,62 +1,50 @@
 
1
  import streamlit as st
2
  import pandas as pd
3
  import joblib
4
  from huggingface_hub import hf_hub_download
5
 
6
- # Download model from Hugging Face
7
- model_path = hf_hub_download(
8
- repo_id="roshra/machine-failure-prediction",
9
- filename="tourism_clean_model.joblib",
10
- repo_type="space"
11
- )
12
  model = joblib.load(model_path)
13
 
14
- st.title("🏖️ Tourism Package Purchase Prediction")
15
-
16
- st.write("Fill in customer details to predict if they will buy a package:")
17
-
18
- # Inputs
19
- age = st.number_input("Age", min_value=18, max_value=100, value=30)
20
- typeofcontact = st.selectbox("Type of Contact", ["Company Invited", "Self Enquiry"])
21
- citytier = st.selectbox("City Tier", [1, 2, 3])
22
- duration = st.number_input("Duration of Pitch", min_value=1, max_value=100, value=20)
23
- num_persons = st.number_input("Number of Persons Visiting", min_value=1, max_value=10, value=2)
24
- followups = st.number_input("Number of Followups", min_value=0, max_value=10, value=2)
25
- star = st.selectbox("Preferred Property Star", [3, 4, 5])
26
- marital = st.selectbox("Marital Status", ["Married", "Single", "Divorced"])
27
- trips = st.number_input("Number of Trips", min_value=0, max_value=20, value=2)
28
- passport = st.selectbox("Passport", [0, 1])
29
- income = st.number_input("Monthly Income", min_value=1000, max_value=100000, value=50000)
30
- satisfaction = st.slider("Pitch Satisfaction Score", 1, 5, 3)
31
- owncar = st.selectbox("Own Car", [0, 1])
32
- children = st.number_input("Number of Children Visiting", min_value=0, max_value=5, value=1)
33
- designation = st.selectbox("Designation", ["Executive", "Manager", "Senior Manager", "AVP", "VP"])
34
- product = st.selectbox("Product Pitched", ["Basic", "Standard", "Deluxe", "Super Deluxe", "King"])
35
-
36
- # Prediction
37
- if st.button("Predict"):
38
  input_df = pd.DataFrame([{
39
  "Age": age,
40
- "TypeofContact": typeofcontact,
41
- "CityTier": citytier,
42
- "DurationOfPitch": duration,
43
- "NumberOfPersonVisiting": num_persons,
44
- "NumberOfFollowups": followups,
45
- "PreferredPropertyStar": star,
46
- "MaritalStatus": marital,
47
- "NumberOfTrips": trips,
48
- "Passport": passport,
49
  "MonthlyIncome": income,
50
- "PitchSatisfactionScore": satisfaction,
51
- "OwnCar": owncar,
52
- "NumberOfChildrenVisiting": children,
53
- "Designation": designation,
54
- "ProductPitched": product
55
  }])
56
 
57
  prediction = model.predict(input_df)[0]
58
  if prediction == 1:
59
- st.success("✅ Likely to Purchase the Package!")
60
  else:
61
- st.error("❌ Not Likely to Purchase the Package")
 
62
 
 
1
+ # week_3_mls/deployment/app.py
2
  import streamlit as st
3
  import pandas as pd
4
  import joblib
5
  from huggingface_hub import hf_hub_download
6
 
7
+ # Load model from HF Hub
8
+ MODEL_REPO = "roshra/machine-failure-prediction"
9
+ MODEL_FILE = "tourism_clean_model.joblib"
10
+
11
+ model_path = hf_hub_download(repo_id=MODEL_REPO, filename=MODEL_FILE, repo_type="space")
 
12
  model = joblib.load(model_path)
13
 
14
+ st.title("🧳 Tourism Package Purchase Prediction App")
15
+ st.write("Fill in details to predict if the customer will purchase the package.")
16
+
17
+ # UI inputs
18
+ age = st.number_input("Age", 18, 100, 30)
19
+ duration = st.number_input("Trip Duration (days)", 1, 30, 5)
20
+ adults = st.number_input("Number of Adults", 1, 10, 2)
21
+ children = st.number_input("Number of Children", 0, 10, 0)
22
+ income = st.number_input("Monthly Income", 1000, 200000, 30000)
23
+
24
+ prop = st.selectbox("Preferred Property", ["Hotel", "Resort", "Guest House", "Other"])
25
+ travel = st.selectbox("Mode of Travel", ["Air", "Train", "Car", "Bus"])
26
+ gender = st.selectbox("Gender", ["Male", "Female", "Other"])
27
+ occupation = st.selectbox("Occupation", ["Salaried", "Self-Employed", "Business", "Other"])
28
+ marital = st.selectbox("Marital Status", ["Single", "Married", "Divorced", "Other"])
29
+
30
+ if st.button("Predict Purchase"):
 
 
 
 
 
 
 
31
  input_df = pd.DataFrame([{
32
  "Age": age,
33
+ "Duration": duration,
34
+ "NumberOfAdults": adults,
35
+ "NumberOfChildren": children,
 
 
 
 
 
 
36
  "MonthlyIncome": income,
37
+ "PreferredProperty": prop,
38
+ "ModeOfTravel": travel,
39
+ "Gender": gender,
40
+ "Occupation": occupation,
41
+ "MaritalStatus": marital
42
  }])
43
 
44
  prediction = model.predict(input_df)[0]
45
  if prediction == 1:
46
+ st.success("✅ Customer is likely to purchase the package!")
47
  else:
48
+ st.error("❌ Customer is unlikely to purchase the package.")
49
+
50