File size: 2,748 Bytes
8c6a54b
 
 
 
 
 
ee27998
 
8c6a54b
ee27998
8c6a54b
 
 
 
 
 
ee27998
 
 
8c6a54b
 
ee27998
8c6a54b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ee27998
8c6a54b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ee27998
8c6a54b
 
 
 
 
ee27998
8c6a54b
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69


# app.py
import streamlit as st
import pandas as pd
import pickle
from huggingface_hub import hf_hub_download
import joblib

# App title
st.title("Customer Status Prediction")

st.write("""
This web app predicts the **status** of a customer based on their activity and profile information.
""")

# Download and load the model
model_path = hf_hub_download(repo_id="NaikGayatri/ModelDeploymentAssignmentBackEnd", filename="my_model_v1_0.joblib")
model = joblib.load(model_path)


# Create UI for user input
st.sidebar.header("Provide Input Features")

# Numeric Inputs
age = st.sidebar.number_input("Age", min_value=0, max_value=100, value=25)
website_visits = st.sidebar.number_input("Website Visits", min_value=0, value=5)
time_spent_on_website = st.sidebar.number_input("Time Spent on Website (minutes)", min_value=0, value=10)
page_views_per_visit = st.sidebar.number_input("Page Views per Visit", min_value=0, value=3)

# Categorical Inputs (replace options with actual categories)
current_occupation = st.sidebar.selectbox("Current Occupation", ["Student", "Professional", "Other"])
first_interaction = st.sidebar.selectbox("First Interaction", ["Email", "Social Media", "Referral", "Other"])
profile_completed = st.sidebar.selectbox("Profile Completed", ["Yes", "No"])
last_activity = st.sidebar.selectbox("Last Activity", ["Last week", "Last month", "Older"])
print_media_type1 = st.sidebar.selectbox("Print Media Type 1", ["Magazine", "Newspaper", "None"])
print_media_type2 = st.sidebar.selectbox("Print Media Type 2", ["Magazine", "Newspaper", "None"])
digital_media = st.sidebar.selectbox("Digital Media", ["Email", "Social Media", "Other"])
educational_channels = st.sidebar.selectbox("Educational Channels", ["Online Course", "Webinar", "None"])
referral = st.sidebar.selectbox("Referral", ["Friend", "Advertisement", "Other"])

# Convert user input to DataFrame
input_dict = {
    'age': age,
    'website_visits': website_visits,
    'time_spent_on_website': time_spent_on_website,
    'page_views_per_visit': page_views_per_visit,
    'current_occupation': current_occupation,
    'first_interaction': first_interaction,
    'profile_completed': profile_completed,
    'last_activity': last_activity,
    'print_media_type1': print_media_type1,
    'print_media_type2': print_media_type2,
    'digital_media': digital_media,
    'educational_channels': educational_channels,
    'referral': referral
}

input_df = pd.DataFrame([input_dict])

# Make prediction
if st.button("Predict Status"):
    prediction = model.predict(input_df)
    prediction_proba = model.predict_proba(input_df)[:, 1]

    st.write(f"**Predicted Status:** {prediction[0]}")
###    st.write(f"**Probability of Positive Status:** {prediction_proba[0]:.2f}")