singhina commited on
Commit
a9e9f21
·
1 Parent(s): ab1799f

Deploy Streamlit frontend with app.py entrypoint and backend linkage

Browse files
Files changed (2) hide show
  1. app.py +54 -0
  2. huggingface.yml +1 -1
app.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ # Redirect HOME so Streamlit can write config without root permission
3
+ os.environ["HOME"] = "/tmp"
4
+ # Disable usage stats to avoid writing to protected dirs
5
+ os.environ["STREAMLIT_GATHER_USAGE_STATS"] = "false"
6
+
7
+ import streamlit as st
8
+ import requests
9
+ import pandas as pd
10
+
11
+ # Page config
12
+ st.set_page_config(page_title="ExtraaLearn Lead Converter", layout="centered")
13
+ st.title("🎓 ExtraaLearn Lead Conversion")
14
+ st.write("Enter lead details and click Predict.")
15
+
16
+ # Input widgets
17
+ age = st.number_input("Age", 18, 100, 30)
18
+ visits = st.number_input("Website Visits", 0, 50, 1)
19
+ time_spent = st.number_input("Time Spent on Website (s)", 0, 5000, 300)
20
+ pages = st.number_input("Page Views per Visit", 1, 20, 3)
21
+
22
+ occ = st.selectbox("Current Occupation", ["Professional","Unemployed","Student"])
23
+ first_int = st.selectbox("First Interaction", ["Website","Mobile App"])
24
+ profile = st.selectbox("Profile Completed", ["Low","Medium","High"])
25
+ print1 = st.checkbox("Saw Newspaper Ad")
26
+ print2 = st.checkbox("Saw Magazine Ad")
27
+ digital = st.checkbox("Saw Digital Ad")
28
+ edu_chan = st.checkbox("Heard via Education Channels")
29
+ referral = st.checkbox("Heard via Referral")
30
+ last_act = st.selectbox("Last Activity", ["Email Activity","Phone Activity","Website Activity"])
31
+
32
+ if st.button("Predict"):
33
+ payload = {
34
+ "age": age,
35
+ "website_visits": visits,
36
+ "time_spent_on_website": time_spent,
37
+ "page_views_per_visit": pages,
38
+ "current_occupation": occ,
39
+ "first_interaction": first_int,
40
+ "profile_completed": profile,
41
+ "print_media_type1": int(print1),
42
+ "print_media_type2": int(print2),
43
+ "digital_media": int(digital),
44
+ "educational_channels": int(edu_chan),
45
+ "referral": int(referral),
46
+ "last_activity": last_act
47
+ }
48
+ # Call the backend predict endpoint
49
+ resp = requests.post("https://huggingface.co/spaces/singhina/ExtraaLeanBackend/predict", json=payload)
50
+ if resp.ok:
51
+ res = resp.json()
52
+ st.success(f"Conversion: {res['prediction']} (Prob: {res['probability']:.2f})")
53
+ else:
54
+ st.error(f"Error {resp.status_code}: {resp.text}")
huggingface.yml CHANGED
@@ -1,2 +1,2 @@
1
  sdk: streamlit
2
- app_file: streamlit_app.py
 
1
  sdk: streamlit
2
+ app_file: app.py