Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -19,7 +19,8 @@ first_interaction = st.selectbox("First Interaction", [
|
|
| 19 |
"Website", "Mobile App", "Referral", "Advertisement", "Social Media"
|
| 20 |
])
|
| 21 |
|
| 22 |
-
|
|
|
|
| 23 |
|
| 24 |
website_visits = st.number_input("Website Visits", min_value=0, max_value=100, step=1, value=15)
|
| 25 |
|
|
@@ -42,7 +43,7 @@ input_data = {
|
|
| 42 |
'age': age,
|
| 43 |
'currentOccupation': current_occupation,
|
| 44 |
'firstInteraction': first_interaction,
|
| 45 |
-
'profileCompleted': profile_completed,
|
| 46 |
'websiteVisits': website_visits,
|
| 47 |
'timeSpentOnWebsite': time_spent_on_website,
|
| 48 |
'pageViewsPerVisit': page_views_per_visit,
|
|
@@ -133,7 +134,7 @@ if uploaded_file is not None and st.button("Predict Batch"):
|
|
| 133 |
|
| 134 |
except requests.exceptions.RequestException as e:
|
| 135 |
st.error(f"Connection error: {e}")
|
| 136 |
-
except Exception as e:
|
| 137 |
st.error(f"Unexpected error: {e}")
|
| 138 |
|
| 139 |
# Add information section
|
|
@@ -142,11 +143,11 @@ if st.button("Check API Status"):
|
|
| 142 |
try:
|
| 143 |
response = requests.get("https://manasranjanpani-extraalearncustomerpredictionbackend.hf.space/ping")
|
| 144 |
if response.status_code == 200:
|
| 145 |
-
st.success("API is running and responsive")
|
| 146 |
else:
|
| 147 |
-
st.error("API is not responding properly")
|
| 148 |
except:
|
| 149 |
-
st.error("Cannot connect to API")
|
| 150 |
|
| 151 |
# Add sample CSV download
|
| 152 |
st.subheader("Sample CSV for Batch Prediction")
|
|
@@ -154,7 +155,7 @@ sample_data = {
|
|
| 154 |
'age': [25, 30, 35],
|
| 155 |
'currentOccupation': ['Student', 'Employed', 'Self-Employed'],
|
| 156 |
'firstInteraction': ['Website', 'Mobile App', 'Referral'],
|
| 157 |
-
'profileCompleted': [
|
| 158 |
'websiteVisits': [15, 20, 10],
|
| 159 |
'timeSpentOnWebsite': [1200, 1500, 900],
|
| 160 |
'pageViewsPerVisit': [8, 10, 6],
|
|
@@ -185,7 +186,7 @@ with st.expander("Required Fields Information"):
|
|
| 185 |
- **age**: Customer age (15-80)
|
| 186 |
- **currentOccupation**: Student, Unemployed, Employed, Self-Employed, Professional
|
| 187 |
- **firstInteraction**: How the customer first interacted with ExtraaLearn
|
| 188 |
-
- **profileCompleted**:
|
| 189 |
- **websiteVisits**: Number of website visits
|
| 190 |
- **timeSpentOnWebsite**: Total time spent on website in seconds
|
| 191 |
- **pageViewsPerVisit**: Average page views per visit
|
|
|
|
| 19 |
"Website", "Mobile App", "Referral", "Advertisement", "Social Media"
|
| 20 |
])
|
| 21 |
|
| 22 |
+
# Updated: profileCompleted as dropdown with High/Medium/Low
|
| 23 |
+
profile_completed = st.selectbox("Profile Completed", ["High", "Medium", "Low"])
|
| 24 |
|
| 25 |
website_visits = st.number_input("Website Visits", min_value=0, max_value=100, step=1, value=15)
|
| 26 |
|
|
|
|
| 43 |
'age': age,
|
| 44 |
'currentOccupation': current_occupation,
|
| 45 |
'firstInteraction': first_interaction,
|
| 46 |
+
'profileCompleted': profile_completed, # This will now be "High", "Medium", or "Low"
|
| 47 |
'websiteVisits': website_visits,
|
| 48 |
'timeSpentOnWebsite': time_spent_on_website,
|
| 49 |
'pageViewsPerVisit': page_views_per_visit,
|
|
|
|
| 134 |
|
| 135 |
except requests.exceptions.RequestException as e:
|
| 136 |
st.error(f"Connection error: {e}")
|
| 137 |
+
except Exception as Exception as e:
|
| 138 |
st.error(f"Unexpected error: {e}")
|
| 139 |
|
| 140 |
# Add information section
|
|
|
|
| 143 |
try:
|
| 144 |
response = requests.get("https://manasranjanpani-extraalearncustomerpredictionbackend.hf.space/ping")
|
| 145 |
if response.status_code == 200:
|
| 146 |
+
st.success("✅ API is running and responsive")
|
| 147 |
else:
|
| 148 |
+
st.error("❌ API is not responding properly")
|
| 149 |
except:
|
| 150 |
+
st.error("❌ Cannot connect to API")
|
| 151 |
|
| 152 |
# Add sample CSV download
|
| 153 |
st.subheader("Sample CSV for Batch Prediction")
|
|
|
|
| 155 |
'age': [25, 30, 35],
|
| 156 |
'currentOccupation': ['Student', 'Employed', 'Self-Employed'],
|
| 157 |
'firstInteraction': ['Website', 'Mobile App', 'Referral'],
|
| 158 |
+
'profileCompleted': ['High', 'Medium', 'Low'], # Updated to use High/Medium/Low
|
| 159 |
'websiteVisits': [15, 20, 10],
|
| 160 |
'timeSpentOnWebsite': [1200, 1500, 900],
|
| 161 |
'pageViewsPerVisit': [8, 10, 6],
|
|
|
|
| 186 |
- **age**: Customer age (15-80)
|
| 187 |
- **currentOccupation**: Student, Unemployed, Employed, Self-Employed, Professional
|
| 188 |
- **firstInteraction**: How the customer first interacted with ExtraaLearn
|
| 189 |
+
- **profileCompleted**: Level of profile completion (High/Medium/Low)
|
| 190 |
- **websiteVisits**: Number of website visits
|
| 191 |
- **timeSpentOnWebsite**: Total time spent on website in seconds
|
| 192 |
- **pageViewsPerVisit**: Average page views per visit
|