NaikGayatri commited on
Commit
ee27998
·
verified ·
1 Parent(s): 080149f

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. app.py +10 -10
  2. requirements.txt +1 -0
app.py CHANGED
@@ -4,22 +4,22 @@
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
- # Load the trained model
15
- @st.cache_resource
16
- def load_model():
17
- return joblib.load("my_model_v1_0.joblib")
18
 
19
- model = load_model()
 
 
20
 
21
 
22
- # 3️⃣ Create UI for user input
23
  st.sidebar.header("Provide Input Features")
24
 
25
  # Numeric Inputs
@@ -39,7 +39,7 @@ digital_media = st.sidebar.selectbox("Digital Media", ["Email", "Social Media",
39
  educational_channels = st.sidebar.selectbox("Educational Channels", ["Online Course", "Webinar", "None"])
40
  referral = st.sidebar.selectbox("Referral", ["Friend", "Advertisement", "Other"])
41
 
42
- # 4️⃣ Convert user input to DataFrame
43
  input_dict = {
44
  'age': age,
45
  'website_visits': website_visits,
@@ -58,11 +58,11 @@ input_dict = {
58
 
59
  input_df = pd.DataFrame([input_dict])
60
 
61
- # 5️⃣ Make prediction
62
  if st.button("Predict Status"):
63
  prediction = model.predict(input_df)
64
  prediction_proba = model.predict_proba(input_df)[:, 1]
65
 
66
  st.write(f"**Predicted Status:** {prediction[0]}")
67
- st.write(f"**Probability of Positive Status:** {prediction_proba[0]:.2f}")
68
 
 
4
  import streamlit as st
5
  import pandas as pd
6
  import pickle
7
+ from huggingface_hub import hf_hub_download
8
+ import joblib
9
 
10
+ # App title
11
  st.title("Customer Status Prediction")
12
 
13
  st.write("""
14
  This web app predicts the **status** of a customer based on their activity and profile information.
15
  """)
 
 
 
 
16
 
17
+ # Download and load the model
18
+ model_path = hf_hub_download(repo_id="NaikGayatri/ModelDeploymentAssignmentBackEnd", filename="my_model_v1_0.joblib")
19
+ model = joblib.load(model_path)
20
 
21
 
22
+ # Create UI for user input
23
  st.sidebar.header("Provide Input Features")
24
 
25
  # Numeric Inputs
 
39
  educational_channels = st.sidebar.selectbox("Educational Channels", ["Online Course", "Webinar", "None"])
40
  referral = st.sidebar.selectbox("Referral", ["Friend", "Advertisement", "Other"])
41
 
42
+ # Convert user input to DataFrame
43
  input_dict = {
44
  'age': age,
45
  'website_visits': website_visits,
 
58
 
59
  input_df = pd.DataFrame([input_dict])
60
 
61
+ # Make prediction
62
  if st.button("Predict Status"):
63
  prediction = model.predict(input_df)
64
  prediction_proba = model.predict_proba(input_df)[:, 1]
65
 
66
  st.write(f"**Predicted Status:** {prediction[0]}")
67
+ ### st.write(f"**Probability of Positive Status:** {prediction_proba[0]:.2f}")
68
 
requirements.txt CHANGED
@@ -4,3 +4,4 @@ scikit-learn==1.6.1
4
  xgboost==2.1.4
5
  joblib==1.4.2
6
  streamlit==1.43.2
 
 
4
  xgboost==2.1.4
5
  joblib==1.4.2
6
  streamlit==1.43.2
7
+ huggingface_hub==0.32.6