Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -10,16 +10,18 @@ st.title("ExtraaLearn Lead Conversion Predictor")
|
|
| 10 |
age = st.number_input("Age", min_value=18, max_value=100, value=45)
|
| 11 |
current_occupation = st.selectbox("Current Occupation", ["Professional", "Unemployed", "Student"])
|
| 12 |
first_interaction = st.selectbox("First Interaction", ["Website", "Mobile App"])
|
| 13 |
-
profile_completed = st.selectbox("Profile Completed", ["Low", "Medium", "High"])
|
| 14 |
website_visits = st.number_input("Website Visits", min_value=0, max_value=50, value=3)
|
| 15 |
time_spent_on_website = st.number_input("Time Spent on Website (seconds)", min_value=0, value=500)
|
| 16 |
page_views_per_visit = st.number_input("Page Views Per Visit", min_value=0.0, value=3.0)
|
| 17 |
last_activity = st.selectbox("Last Activity", ["Email Activity", "Phone Activity", "Website Activity"])
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
| 23 |
|
| 24 |
# Prepare the data dictionary for the API
|
| 25 |
lead_data = {
|
|
@@ -40,15 +42,14 @@ lead_data = {
|
|
| 40 |
|
| 41 |
if st.button("Predict Propensity", type='primary'):
|
| 42 |
# API URL for your Docker Backend
|
| 43 |
-
api_url = "https://sirisha335-extraalearn-api.hf.space/v1/predict"
|
| 44 |
-
|
| 45 |
with st.spinner("Connecting to API..."):
|
| 46 |
try:
|
| 47 |
response = requests.post(api_url, json=lead_data, timeout=10)
|
| 48 |
if response.status_code == 200:
|
| 49 |
result = response.json()
|
| 50 |
-
|
| 51 |
-
prediction = result.get("Sales", 0)
|
| 52 |
st.metric("Conversion Propensity", f"{prediction:.4f}")
|
| 53 |
if prediction > 0.5:
|
| 54 |
st.success("This lead is highly likely to convert!")
|
|
|
|
| 10 |
age = st.number_input("Age", min_value=18, max_value=100, value=45)
|
| 11 |
current_occupation = st.selectbox("Current Occupation", ["Professional", "Unemployed", "Student"])
|
| 12 |
first_interaction = st.selectbox("First Interaction", ["Website", "Mobile App"])
|
| 13 |
+
profile_completed = st.selectbox("Profile Completed", ["Low", "Medium", "High"], index=2) # Default High
|
| 14 |
website_visits = st.number_input("Website Visits", min_value=0, max_value=50, value=3)
|
| 15 |
time_spent_on_website = st.number_input("Time Spent on Website (seconds)", min_value=0, value=500)
|
| 16 |
page_views_per_visit = st.number_input("Page Views Per Visit", min_value=0.0, value=3.0)
|
| 17 |
last_activity = st.selectbox("Last Activity", ["Email Activity", "Phone Activity", "Website Activity"])
|
| 18 |
+
|
| 19 |
+
# Marketing Channels - Setting defaults to 'No' (index 1)
|
| 20 |
+
print_media_type1 = st.selectbox("Saw Ad in Newspaper?", ["Yes", "No"], index=1)
|
| 21 |
+
print_media_type2 = st.selectbox("Saw Ad in Magazine?", ["Yes", "No"], index=1)
|
| 22 |
+
digital_media = st.selectbox("Saw Ad on Digital Platforms?", ["Yes", "No"], index=1)
|
| 23 |
+
educational_channels = st.selectbox("Heard via Educational Channels?", ["Yes", "No"], index=1)
|
| 24 |
+
referral = st.selectbox("Heard via Referral?", ["Yes", "No"], index=1)
|
| 25 |
|
| 26 |
# Prepare the data dictionary for the API
|
| 27 |
lead_data = {
|
|
|
|
| 42 |
|
| 43 |
if st.button("Predict Propensity", type='primary'):
|
| 44 |
# API URL for your Docker Backend
|
| 45 |
+
api_url = "https://sirisha335-extraalearn-api.hf.space/v1/predict" # Assuming the endpoint name remains /v1/predict
|
| 46 |
+
|
| 47 |
with st.spinner("Connecting to API..."):
|
| 48 |
try:
|
| 49 |
response = requests.post(api_url, json=lead_data, timeout=10)
|
| 50 |
if response.status_code == 200:
|
| 51 |
result = response.json()
|
| 52 |
+
prediction = result.get("Conversion_Probability", 0) # Changed key to Conversion_Probability
|
|
|
|
| 53 |
st.metric("Conversion Propensity", f"{prediction:.4f}")
|
| 54 |
if prediction > 0.5:
|
| 55 |
st.success("This lead is highly likely to convert!")
|