File size: 2,087 Bytes
ab1799f
 
 
 
 
 
31b89f6
ab1799f
 
31b89f6
 
 
 
 
 
 
 
 
ab1799f
31b89f6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ab1799f
31b89f6
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import os
# Redirect HOME so Streamlit can write config without root permissions
os.environ["HOME"] = "/tmp"
# Disable usage statistics to avoid writing to protected dirs
os.environ["STREAMLIT_GATHER_USAGE_STATS"] = "false"

import streamlit as st
import requests
import pandas as pd

st.set_page_config(page_title="ExtraaLearn Lead Converter", layout="centered")
st.title("πŸŽ“ ExtraaLearn Lead Conversion")
st.write("Enter lead details and click Predict.")

# Input widgets
age = st.number_input("Age", 18, 100, 30)
visits = st.number_input("Website Visits", 0, 50, 1)
time_spent = st.number_input("Time Spent on Website (s)", 0, 5000, 300)
pages = st.number_input("Page Views per Visit", 1, 20, 3)

occ = st.selectbox("Current Occupation", ["Professional","Unemployed","Student"])
first_int = st.selectbox("First Interaction", ["Website","Mobile App"])
profile = st.selectbox("Profile Completed", ["Low","Medium","High"])
print1 = st.checkbox("Saw Newspaper Ad")
print2 = st.checkbox("Saw Magazine Ad")
digital = st.checkbox("Saw Digital Ad")
edu_chan = st.checkbox("Heard via Education Channels")
referral = st.checkbox("Heard via Referral")
last_act = st.selectbox("Last Activity", ["Email Activity","Phone Activity","Website Activity"])

if st.button("Predict"):
    payload = {
        "age": age,
        "website_visits": visits,
        "time_spent_on_website": time_spent,
        "page_views_per_visit": pages,
        "current_occupation": occ,
        "first_interaction": first_int,
        "profile_completed": profile,
        "print_media_type1": int(print1),
        "print_media_type2": int(print2),
        "digital_media": int(digital),
        "educational_channels": int(edu_chan),
        "referral": int(referral),
        "last_activity": last_act
    }
    resp = requests.post("https://huggingface.co/spaces/singhina/ExtraaLeanBackend/predict", json=payload)
    if resp.ok:
        res = resp.json()
        st.success(f"Conversion: {res['prediction']} (Prob: {res['probability']:.2f})")
    else:
        st.error(f"Error {resp.status_code}: {resp.text}")