RohitMV commited on
Commit
7bf2bfa
Β·
verified Β·
1 Parent(s): 7607c02

Update src/app.py

Browse files
Files changed (1) hide show
  1. src/app.py +41 -25
src/app.py CHANGED
@@ -8,11 +8,11 @@ st.set_page_config(
8
 
9
  st.title("πŸŽ“ ExtraaLearn Lead Conversion Prediction")
10
 
11
- st.write("Enter lead details to predict conversion likelihood.")
12
 
13
  # ---------------- INPUT FIELDS ---------------- #
14
 
15
- age = st.number_input("Age", min_value=18, max_value=70, value=28)
16
 
17
  current_occupation = st.selectbox(
18
  "Current Occupation",
@@ -20,38 +20,56 @@ current_occupation = st.selectbox(
20
  )
21
 
22
  first_interaction = st.selectbox(
23
- "First Interaction Channel",
24
  ["Website", "Email", "Referral", "Social Media"]
25
  )
26
 
27
  profile_completed = st.selectbox(
28
- "Profile Completed?",
29
- ["Yes", "No"]
30
  )
31
 
32
  website_visits = st.number_input(
33
- "Website Visits", min_value=0, max_value=100, value=5
34
  )
35
 
36
  time_spent_on_website = st.number_input(
37
- "Time Spent on Website (minutes)", min_value=0.0, value=10.0
38
  )
39
 
40
  page_views_per_visit = st.number_input(
41
- "Page Views per Visit", min_value=0.0, value=3.5
42
  )
43
 
44
  last_activity = st.selectbox(
45
  "Last Activity",
46
- ["Email Opened", "SMS Clicked", "Website Visit", "Form Submitted"]
 
 
 
 
 
47
  )
48
 
49
- # Binary media flags (VERY IMPORTANT)
50
- print_media_type1 = st.checkbox("Print Media Type 1")
51
- print_media_type2 = st.checkbox("Print Media Type 2")
52
- digital_media = st.checkbox("Digital Media")
53
- educational_channels = st.checkbox("Educational Channels")
54
- referral = st.checkbox("Referral")
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
  # ---------------- PREDICT ---------------- #
57
 
@@ -62,21 +80,20 @@ if st.button("Predict Conversion"):
62
  "age": age,
63
  "current_occupation": current_occupation,
64
  "first_interaction": first_interaction,
65
- "profile_completed": 1 if profile_completed == "Yes" else 0,
66
  "website_visits": website_visits,
67
  "time_spent_on_website": time_spent_on_website,
68
  "page_views_per_visit": page_views_per_visit,
69
  "last_activity": last_activity,
70
- "print_media_type1": int(print_media_type1),
71
- "print_media_type2": int(print_media_type2),
72
- "digital_media": int(digital_media),
73
- "educational_channels": int(educational_channels),
74
- "referral": int(referral)
75
  }
76
  ]
77
  }
78
 
79
- # πŸ”΄ Replace with your actual backend URL
80
  BACKEND_URL = "https://rohitmv-extra-learn-be.hf.space/predict"
81
 
82
  try:
@@ -92,11 +109,10 @@ if st.button("Predict Conversion"):
92
  f"{int(result['conversion_probability'] * 100)}%"
93
  )
94
 
95
- st.write("### Prediction")
96
  st.write(
97
- "βœ… Likely to Convert"
98
  if result["prediction"] == 1
99
- else "❌ Unlikely to Convert"
100
  )
101
 
102
  st.write(f"**Lead Category:** {result['lead_category']}")
 
8
 
9
  st.title("πŸŽ“ ExtraaLearn Lead Conversion Prediction")
10
 
11
+ st.write("Fill in the lead details below to predict conversion likelihood.")
12
 
13
  # ---------------- INPUT FIELDS ---------------- #
14
 
15
+ age = st.number_input("Age", min_value=18, max_value=80, value=57)
16
 
17
  current_occupation = st.selectbox(
18
  "Current Occupation",
 
20
  )
21
 
22
  first_interaction = st.selectbox(
23
+ "First Interaction",
24
  ["Website", "Email", "Referral", "Social Media"]
25
  )
26
 
27
  profile_completed = st.selectbox(
28
+ "Profile Completion Level",
29
+ ["Low", "Medium", "High"]
30
  )
31
 
32
  website_visits = st.number_input(
33
+ "Website Visits", min_value=0, max_value=100, value=7
34
  )
35
 
36
  time_spent_on_website = st.number_input(
37
+ "Time Spent on Website (seconds)", min_value=0, value=1639
38
  )
39
 
40
  page_views_per_visit = st.number_input(
41
+ "Page Views per Visit", min_value=0.0, value=1.861
42
  )
43
 
44
  last_activity = st.selectbox(
45
  "Last Activity",
46
+ ["Website Activity", "Email Opened", "SMS Clicked", "Form Submitted"]
47
+ )
48
+
49
+ print_media_type1 = st.selectbox(
50
+ "Print Media Type 1",
51
+ ["Yes", "No"]
52
  )
53
 
54
+ print_media_type2 = st.selectbox(
55
+ "Print Media Type 2",
56
+ ["Yes", "No"]
57
+ )
58
+
59
+ digital_media = st.selectbox(
60
+ "Digital Media",
61
+ ["Yes", "No"]
62
+ )
63
+
64
+ educational_channels = st.selectbox(
65
+ "Educational Channels",
66
+ ["Yes", "No"]
67
+ )
68
+
69
+ referral = st.selectbox(
70
+ "Referral",
71
+ ["Yes", "No"]
72
+ )
73
 
74
  # ---------------- PREDICT ---------------- #
75
 
 
80
  "age": age,
81
  "current_occupation": current_occupation,
82
  "first_interaction": first_interaction,
83
+ "profile_completed": profile_completed,
84
  "website_visits": website_visits,
85
  "time_spent_on_website": time_spent_on_website,
86
  "page_views_per_visit": page_views_per_visit,
87
  "last_activity": last_activity,
88
+ "print_media_type1": 1 if print_media_type1 == "Yes" else 0,
89
+ "print_media_type2": 1 if print_media_type2 == "Yes" else 0,
90
+ "digital_media": 1 if digital_media == "Yes" else 0,
91
+ "educational_channels": 1 if educational_channels == "Yes" else 0,
92
+ "referral": 1 if referral == "Yes" else 0
93
  }
94
  ]
95
  }
96
 
 
97
  BACKEND_URL = "https://rohitmv-extra-learn-be.hf.space/predict"
98
 
99
  try:
 
109
  f"{int(result['conversion_probability'] * 100)}%"
110
  )
111
 
 
112
  st.write(
113
+ "### βœ… Likely to Convert"
114
  if result["prediction"] == 1
115
+ else "### ❌ Unlikely to Convert"
116
  )
117
 
118
  st.write(f"**Lead Category:** {result['lead_category']}")