ShantanuChande commited on
Commit
e1949a0
·
verified ·
1 Parent(s): 09e55ec

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. Dockerfile +22 -0
  2. app.py +70 -0
  3. requirements.txt +4 -0
Dockerfile ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # Use an official lightweight Python image
3
+ FROM python:3.9-slim
4
+
5
+ # Set the working directory inside the container
6
+ WORKDIR /app
7
+
8
+ # Copy the requirements file first to take advantage of Docker caching
9
+ COPY requirements.txt .
10
+
11
+ # Install the dependencies
12
+ RUN pip install --no-cache-dir -r requirements.txt
13
+
14
+ # Copy the rest of the application code
15
+ COPY . .
16
+
17
+ # Expose the port Streamlit will run on (Hugging Face Spaces uses 7860)
18
+ EXPOSE 7860
19
+
20
+ # Command to run the Streamlit app
21
+ # We bind to 0.0.0.0 and port 7860 for cloud compatibility
22
+ CMD ["streamlit", "run", "app.py", "--server.port", "7860", "--server.address", "0.0.0.0"]
app.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import streamlit as st
3
+ import requests
4
+
5
+ # Set page title and icon
6
+ st.set_page_config(page_title="ExtraaLearn Lead Prediction", page_icon="🎓")
7
+
8
+ st.title("🎓 ExtraaLearn: Lead Conversion Prediction")
9
+ st.markdown("Enter lead details below to predict the likelihood of conversion.")
10
+
11
+ # Layout with columns for better UI
12
+ col1, col2 = st.columns(2)
13
+
14
+ with col1:
15
+ age = st.number_input("Age", min_value=18, max_value=65, value=25)
16
+ current_occupation = st.selectbox("Current Occupation", ["Student", "Professional", "Unemployed", "Others"])
17
+ first_interaction = st.selectbox("First Interaction", ["Website", "Mobile App"])
18
+ profile_completed = st.slider("Profile Completed (%)", 0, 100, 50)
19
+ website_visits = st.number_input("Website Visits", min_value=0, value=5)
20
+ referral = st.selectbox("Referral", ["No", "Yes"])
21
+
22
+ with col2:
23
+ time_spent_on_website = st.number_input("Time Spent on Website (m)", min_value=0, value=300)
24
+ page_views_per_visit = st.number_input("Page Views Per Visit", min_value=0.0, value=2.5)
25
+ last_activity = st.selectbox("Last Activity", ["Email Opened", "Website Activity", "Mobile App Activity", "Others"])
26
+ print_media_type1 = st.selectbox("Print Media (Type 1)", ["No", "Yes"])
27
+ print_media_type2 = st.selectbox("Print Media (Type 2)", ["No", "Yes"])
28
+ digital_media = st.selectbox("Digital Media", ["No", "Yes"])
29
+ educational_channels = st.selectbox("Educational Channels", ["No", "Yes"])
30
+
31
+ # Prepare the data dictionary for the API
32
+ lead_data = {
33
+ "age": age,
34
+ "current_occupation": current_occupation,
35
+ "first_interaction": first_interaction,
36
+ "profile_completed": profile_completed,
37
+ "website_visits": website_visits,
38
+ "time_spent_on_website": time_spent_on_website,
39
+ "page_views_per_visit": page_views_per_visit,
40
+ "last_activity": last_activity,
41
+ "print_media_type1": print_media_type1,
42
+ "print_media_type2": print_media_type2,
43
+ "digital_media": digital_media,
44
+ "educational_channels": educational_channels,
45
+ "referral": referral
46
+ }
47
+
48
+ st.divider()
49
+
50
+ if st.button("Predict Conversion Potential", type='primary'):
51
+ try:
52
+ # Update the URL below once your backend API is deployed
53
+ api_url = "https://shantanuchande-extlearn-api.hf.space/v1/predict"
54
+ response = requests.post(api_url, json=lead_data)
55
+
56
+ if response.status_code == 200:
57
+ result = response.json()
58
+ prediction = result["Status_Prediction"]
59
+ probability = result["Conversion_Probability"]
60
+
61
+ if prediction == 1:
62
+ st.success(f"### High Potential Lead!!!!")
63
+ st.write(f"Confidence: {probability*100:.2f}%")
64
+ else:
65
+ st.warning(f"### Low Potential Lead")
66
+ st.write(f"Confidence: {(1-probability)*100:.2f}%")
67
+ else:
68
+ st.error(f"Error in API request: {response.status_code}")
69
+ except Exception as e:
70
+ st.error(f"Connection Error: {e}")
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ streamlit
2
+ requests
3
+ pandas
4
+ numpy