NaikGayatri commited on
Commit
8c6a54b
·
verified ·
1 Parent(s): 8abffc8

Upload folder using huggingface_hub

Browse files
app.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ # app.py
4
+ import streamlit as st
5
+ import pandas as pd
6
+ import pickle
7
+
8
+ # 1️⃣ App title
9
+ st.title("Customer Status Prediction")
10
+
11
+ st.write("""
12
+ This web app predicts the **status** of a customer based on their activity and profile information.
13
+ """)
14
+
15
+ # 2️⃣ Load serialized ML model
16
+ @st.cache_data
17
+ def load_model(model_path):
18
+ with open(model_path, "rb") as f:
19
+ model = pickle.load(f)
20
+ return model
21
+
22
+ model = load_model("best_model.pkl") # Replace with your model path
23
+
24
+ # 3️⃣ Create UI for user input
25
+ st.sidebar.header("Provide Input Features")
26
+
27
+ # Numeric Inputs
28
+ age = st.sidebar.number_input("Age", min_value=0, max_value=100, value=25)
29
+ website_visits = st.sidebar.number_input("Website Visits", min_value=0, value=5)
30
+ time_spent_on_website = st.sidebar.number_input("Time Spent on Website (minutes)", min_value=0, value=10)
31
+ page_views_per_visit = st.sidebar.number_input("Page Views per Visit", min_value=0, value=3)
32
+
33
+ # Categorical Inputs (replace options with actual categories)
34
+ current_occupation = st.sidebar.selectbox("Current Occupation", ["Student", "Professional", "Other"])
35
+ first_interaction = st.sidebar.selectbox("First Interaction", ["Email", "Social Media", "Referral", "Other"])
36
+ profile_completed = st.sidebar.selectbox("Profile Completed", ["Yes", "No"])
37
+ last_activity = st.sidebar.selectbox("Last Activity", ["Last week", "Last month", "Older"])
38
+ print_media_type1 = st.sidebar.selectbox("Print Media Type 1", ["Magazine", "Newspaper", "None"])
39
+ print_media_type2 = st.sidebar.selectbox("Print Media Type 2", ["Magazine", "Newspaper", "None"])
40
+ digital_media = st.sidebar.selectbox("Digital Media", ["Email", "Social Media", "Other"])
41
+ educational_channels = st.sidebar.selectbox("Educational Channels", ["Online Course", "Webinar", "None"])
42
+ referral = st.sidebar.selectbox("Referral", ["Friend", "Advertisement", "Other"])
43
+
44
+ # 4️⃣ Convert user input to DataFrame
45
+ input_dict = {
46
+ 'age': age,
47
+ 'website_visits': website_visits,
48
+ 'time_spent_on_website': time_spent_on_website,
49
+ 'page_views_per_visit': page_views_per_visit,
50
+ 'current_occupation': current_occupation,
51
+ 'first_interaction': first_interaction,
52
+ 'profile_completed': profile_completed,
53
+ 'last_activity': last_activity,
54
+ 'print_media_type1': print_media_type1,
55
+ 'print_media_type2': print_media_type2,
56
+ 'digital_media': digital_media,
57
+ 'educational_channels': educational_channels,
58
+ 'referral': referral
59
+ }
60
+
61
+ input_df = pd.DataFrame([input_dict])
62
+
63
+ # 5️⃣ Make prediction
64
+ if st.button("Predict Status"):
65
+ prediction = model.predict(input_df)
66
+ prediction_proba = model.predict_proba(input_df)[:, 1]
67
+
68
+ st.write(f"**Predicted Status:** {prediction[0]}")
69
+ st.write(f"**Probability of Positive Status:** {prediction_proba[0]:.2f}")
70
+
churn_prediction_model_v1_0.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d969348d24e07a223f66fdc507a706e6e8c051b7526625d4dedb6755ceb58307
3
+ size 90101
my_model_v1_0.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d969348d24e07a223f66fdc507a706e6e8c051b7526625d4dedb6755ceb58307
3
+ size 90101
requirements.txt CHANGED
@@ -1,3 +1,6 @@
1
- altair
2
- pandas
3
- streamlit
 
 
 
 
1
+ pandas==2.2.2
2
+ numpy==2.0.2
3
+ scikit-learn==1.6.1
4
+ xgboost==2.1.4
5
+ joblib==1.4.2
6
+ streamlit==1.43.2