Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,52 +5,56 @@ import joblib
|
|
5 |
# Load the bank_df_cleaned for reference
|
6 |
bank_df_cleaned = pd.read_csv('bank_df_cleaned.csv')
|
7 |
|
8 |
-
#
|
9 |
-
|
10 |
-
st.
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
"""
|
|
|
|
|
|
|
|
|
15 |
|
16 |
-
# Load the saved model
|
17 |
-
model = joblib.load("HistGradientBoostingClassifier.joblib")
|
18 |
|
19 |
-
# Input features
|
20 |
-
st.header("Enter the details for prediction:")
|
21 |
|
22 |
-
job = st.selectbox('Job', bank_df_cleaned['job'].unique())
|
23 |
-
marital = st.selectbox('Marital', bank_df_cleaned['marital'].unique())
|
24 |
-
education = st.selectbox('Education', bank_df_cleaned['education'].unique())
|
25 |
-
default = st.selectbox('Default', bank_df_cleaned['default'].unique())
|
26 |
-
housing = st.selectbox('Housing Loan', bank_df_cleaned['housing'].unique())
|
27 |
-
loan = st.selectbox('Personal Loan', bank_df_cleaned['loan'].unique())
|
28 |
-
poutcome = st.selectbox('Previous Outcome', bank_df_cleaned['poutcome'].unique())
|
29 |
-
log_campaign = st.slider('Log Campaign', float(bank_df_cleaned['log_campaign'].min()), float(bank_df_cleaned['log_campaign'].max()))
|
30 |
-
log_duration = st.slider('Log Duration', float(bank_df_cleaned['log_duration'].min()), float(bank_df_cleaned['log_duration'].max()))
|
31 |
-
log_age = st.slider('Log Age', float(bank_df_cleaned['log_age'].min()), float(bank_df_cleaned['log_age'].max()))
|
32 |
-
campaign_duration_interaction = log_campaign * log_duration
|
33 |
-
contact_is_cellular = st.selectbox('Contact is Cellular', [0, 1])
|
34 |
-
total_loans = st.selectbox('Total Loans', [0, 1, 2])
|
35 |
|
36 |
-
data = {
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
}
|
51 |
-
input_df = pd.DataFrame(data)
|
52 |
|
53 |
-
# Make prediction
|
54 |
-
prediction = model.predict(input_df)
|
55 |
-
outcome = "will subscribe to" if prediction[0] == 1 else "will not subscribe to"
|
56 |
-
st.success(f"Prediction: The customer {outcome} term deposit.")
|
|
|
5 |
# Load the bank_df_cleaned for reference
|
6 |
bank_df_cleaned = pd.read_csv('bank_df_cleaned.csv')
|
7 |
|
8 |
+
# Check if 'job' column exists
|
9 |
+
if 'job' not in bank_df_cleaned.columns:
|
10 |
+
st.error("The column 'job' does not exist in the DataFrame.")
|
11 |
+
else:
|
12 |
+
# Title and description
|
13 |
+
st.title("Banking Campaign Outcome Prediction App")
|
14 |
+
st.markdown("""
|
15 |
+
Welcome to the **Banking Campaign Outcome Prediction App**!
|
16 |
+
This tool predicts whether a customer will respond positively to a banking campaign based on their demographic and transactional information.
|
17 |
+
Please input the required details below to get a prediction.
|
18 |
+
""")
|
19 |
|
20 |
+
# Load the saved model
|
21 |
+
model = joblib.load("HistGradientBoostingClassifier.joblib")
|
22 |
|
23 |
+
# Input features
|
24 |
+
st.header("Enter the details for prediction:")
|
25 |
|
26 |
+
job = st.selectbox('Job', bank_df_cleaned['job'].unique())
|
27 |
+
marital = st.selectbox('Marital', bank_df_cleaned['marital'].unique())
|
28 |
+
education = st.selectbox('Education', bank_df_cleaned['education'].unique())
|
29 |
+
default = st.selectbox('Default', bank_df_cleaned['default'].unique())
|
30 |
+
housing = st.selectbox('Housing Loan', bank_df_cleaned['housing'].unique())
|
31 |
+
loan = st.selectbox('Personal Loan', bank_df_cleaned['loan'].unique())
|
32 |
+
poutcome = st.selectbox('Previous Outcome', bank_df_cleaned['poutcome'].unique())
|
33 |
+
log_campaign = st.slider('Log Campaign', float(bank_df_cleaned['log_campaign'].min()), float(bank_df_cleaned['log_campaign'].max()))
|
34 |
+
log_duration = st.slider('Log Duration', float(bank_df_cleaned['log_duration'].min()), float(bank_df_cleaned['log_duration'].max()))
|
35 |
+
log_age = st.slider('Log Age', float(bank_df_cleaned['log_age'].min()), float(bank_df_cleaned['log_age'].max()))
|
36 |
+
campaign_duration_interaction = log_campaign * log_duration
|
37 |
+
contact_is_cellular = st.selectbox('Contact is Cellular', [0, 1])
|
38 |
+
total_loans = st.selectbox('Total Loans', [0, 1, 2])
|
39 |
|
40 |
+
data = {
|
41 |
+
'job': job,
|
42 |
+
'marital': marital,
|
43 |
+
'education': education,
|
44 |
+
'default': default,
|
45 |
+
'housing': housing,
|
46 |
+
'loan': loan,
|
47 |
+
'poutcome': poutcome,
|
48 |
+
'log_campaign': log_campaign,
|
49 |
+
'log_duration': log_duration,
|
50 |
+
'log_age': log_age,
|
51 |
+
'campaign_duration_interaction': campaign_duration_interaction,
|
52 |
+
'contact_is_cellular': contact_is_cellular,
|
53 |
+
'total_loans': total_loans
|
54 |
+
}
|
55 |
+
input_df = pd.DataFrame(data)
|
56 |
|
57 |
+
# Make prediction
|
58 |
+
prediction = model.predict(input_df)
|
59 |
+
outcome = "will subscribe to" if prediction[0] == 1 else "will not subscribe to"
|
60 |
+
st.success(f"Prediction: The customer {outcome} term deposit.")
|