File size: 2,695 Bytes
57e7e31
 
d76fc83
 
dc5f4ca
 
 
4547e81
 
 
 
 
 
 
 
 
 
 
57e7e31
4547e81
 
581e0be
4547e81
 
ff5e5fb
4547e81
 
 
 
 
 
 
 
 
 
 
 
 
581e0be
4547e81
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
581e0be
4547e81
 
 
 
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
import streamlit as st
import pandas as pd
import joblib

# Load the bank_df_cleaned for reference
bank_df_cleaned = pd.read_csv('bank_df_cleaned.csv')

# Check if 'job' column exists
if 'job' not in bank_df_cleaned.columns:
    st.error("The column 'job' does not exist in the DataFrame.")
else:
    # Title and description
    st.title("Banking Campaign Outcome Prediction App")
    st.markdown("""
    Welcome to the **Banking Campaign Outcome Prediction App**!  
    This tool predicts whether a customer will respond positively to a banking campaign based on their demographic and transactional information.  
    Please input the required details below to get a prediction.
    """)

    # Load the saved model
    model = joblib.load("HistGradientBoostingClassifier.joblib")

    # Input features
    st.header("Enter the details for prediction:")

    job = st.selectbox('Job', bank_df_cleaned['job'].unique())
    marital = st.selectbox('Marital', bank_df_cleaned['marital'].unique())
    education = st.selectbox('Education', bank_df_cleaned['education'].unique())
    default = st.selectbox('Default', bank_df_cleaned['default'].unique())
    housing = st.selectbox('Housing Loan', bank_df_cleaned['housing'].unique())
    loan = st.selectbox('Personal Loan', bank_df_cleaned['loan'].unique())
    poutcome = st.selectbox('Previous Outcome', bank_df_cleaned['poutcome'].unique())
    log_campaign = st.slider('Log Campaign', float(bank_df_cleaned['log_campaign'].min()), float(bank_df_cleaned['log_campaign'].max()))
    log_duration = st.slider('Log Duration', float(bank_df_cleaned['log_duration'].min()), float(bank_df_cleaned['log_duration'].max()))
    log_age = st.slider('Log Age', float(bank_df_cleaned['log_age'].min()), float(bank_df_cleaned['log_age'].max()))
    campaign_duration_interaction = log_campaign * log_duration
    contact_is_cellular = st.selectbox('Contact is Cellular', [0, 1])
    total_loans = st.selectbox('Total Loans', [0, 1, 2])

    data = {
        'job': job,
        'marital': marital,
        'education': education,
        'default': default,
        'housing': housing,
        'loan': loan,
        'poutcome': poutcome,
        'log_campaign': log_campaign,
        'log_duration': log_duration,
        'log_age': log_age,
        'campaign_duration_interaction': campaign_duration_interaction,
        'contact_is_cellular': contact_is_cellular,
        'total_loans': total_loans
    }
    input_df = pd.DataFrame(data)

    # Make prediction
    prediction = model.predict(input_df)
    outcome = "will subscribe to" if prediction[0] == 1 else "will not subscribe to"
    st.success(f"Prediction: The customer {outcome} term deposit.")