Disha252001 commited on
Commit
b643cf9
·
1 Parent(s): 3354cdd

Initial Docker Space deployment

Browse files
Files changed (3) hide show
  1. Dockerfile +13 -0
  2. app.py +77 -0
  3. requirements.txt +7 -0
Dockerfile ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ FROM python:3.10-slim
3
+
4
+ WORKDIR /app
5
+
6
+ COPY requirements.txt .
7
+ RUN pip install --no-cache-dir -r requirements.txt
8
+
9
+ COPY . .
10
+
11
+ EXPOSE 7860
12
+
13
+ CMD ["bash", "-c", "streamlit run app.py --server.address 0.0.0.0 --server.port $PORT"]
app.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ os.environ["STREAMLIT_SERVER_ENABLE_CORS"] = "false"
4
+ os.environ["STREAMLIT_SERVER_ENABLE_XSRF_PROTECTION"] = "false"
5
+ import streamlit as st
6
+ import pandas as pd
7
+ from huggingface_hub import hf_hub_download
8
+ import joblib
9
+
10
+ # --------------------------
11
+ # Load trained model from Hugging Face
12
+ # --------------------------
13
+ model_repo_id = "Disha252001/tourism-best-model"
14
+ model_file = "best_model.pkl"
15
+
16
+ local_model_path = hf_hub_download(repo_id=model_repo_id, filename=model_file)
17
+ model = joblib.load(local_model_path)
18
+
19
+ # --------------------------
20
+ # Input form
21
+ # --------------------------
22
+ with st.form("input_form"):
23
+
24
+ Age = st.number_input("Age", min_value=0, max_value=120, value=35)
25
+ TypeofContact = st.selectbox("Type of Contact", ["Company Invited", "Self Inquiry"])
26
+ CityTier = st.selectbox("City Tier", [1, 2, 3], index=1)
27
+ Occupation = st.selectbox("Occupation", ["Salaried", "Freelancer", "Business", "Other"])
28
+ Gender = st.selectbox("Gender", ["Male", "Female"])
29
+ NumberOfPersonVisiting = st.number_input("Number Of Person Visiting", min_value=0, value=2)
30
+ PreferredPropertyStar = st.number_input("Preferred Property Star", min_value=1, max_value=7, value=5)
31
+ MaritalStatus = st.selectbox("Marital Status", ["Single", "Married", "Divorced"])
32
+ NumberOfTrips = st.number_input("Number Of Trips (annual)", min_value=0, value=2)
33
+ Passport = st.selectbox("Passport (0=No,1=Yes)", [0,1], index=1)
34
+ OwnCar = st.selectbox("Own Car (0=No,1=Yes)", [0,1], index=1)
35
+ NumberOfChildrenVisiting = st.number_input("Number Of Children Visiting (below 5)", min_value=0, value=0)
36
+ Designation = st.text_input("Designation", value="Manager")
37
+ MonthlyIncome = st.number_input("Monthly Income", min_value=0, value=50000)
38
+ PitchSatisfactionScore = st.number_input("Pitch Satisfaction Score (1-10)", min_value=0, max_value=10, value=8)
39
+ ProductPitched = st.selectbox("Product Pitched", ["Wellness Package", "Family Package", "Other"])
40
+ NumberOfFollowups = st.number_input("Number Of Followups", min_value=0, value=1)
41
+ DurationOfPitch = st.number_input("Duration Of Pitch (minutes)", min_value=0, value=10)
42
+
43
+ submitted = st.form_submit_button("Predict")
44
+
45
+ # --------------------------
46
+ # Convert inputs to DataFrame
47
+ # --------------------------
48
+ def build_input_df():
49
+ row = {
50
+ "Age": Age,
51
+ "TypeofContact": TypeofContact,
52
+ "CityTier": CityTier,
53
+ "Occupation": Occupation,
54
+ "Gender": Gender,
55
+ "NumberOfPersonVisiting": NumberOfPersonVisiting,
56
+ "PreferredPropertyStar": PreferredPropertyStar,
57
+ "MaritalStatus": MaritalStatus,
58
+ "NumberOfTrips": NumberOfTrips,
59
+ "Passport": Passport,
60
+ "OwnCar": OwnCar,
61
+ "NumberOfChildrenVisiting": NumberOfChildrenVisiting,
62
+ "Designation": Designation,
63
+ "MonthlyIncome": MonthlyIncome,
64
+ "PitchSatisfactionScore": PitchSatisfactionScore,
65
+ "ProductPitched": ProductPitched,
66
+ "NumberOfFollowups": NumberOfFollowups,
67
+ "DurationOfPitch": DurationOfPitch
68
+ }
69
+ return pd.DataFrame([row])
70
+
71
+ # --------------------------
72
+ # Predict and display result
73
+ # --------------------------
74
+ if submitted:
75
+ input_df = build_input_df()
76
+ prediction = model.predict(input_df)
77
+ st.success(f"Predicted ProdTaken: {int(prediction[0])}")
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ streamlit
2
+ pandas
3
+ scikit-learn
4
+ joblib
5
+ huggingface_hub
6
+ datasets
7
+