Spaces:
Sleeping
Sleeping
Sonny4Sonnix
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -7,54 +7,62 @@ import joblib
|
|
7 |
# Load the saved model
|
8 |
#model = joblib.load("HistGradientBoostingClassifier.joblib")
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
# Load the saved model
|
8 |
#model = joblib.load("HistGradientBoostingClassifier.joblib")
|
9 |
|
10 |
+
import streamlit as st
|
11 |
+
import joblib
|
12 |
+
import pandas as pd
|
13 |
+
|
14 |
+
# Load the model
|
15 |
+
model = joblib.load('HistGradientBoostingClassifier.joblib')
|
16 |
+
|
17 |
+
# Title of the app
|
18 |
+
st.title('Bank Term Deposit Prediction App')
|
19 |
+
|
20 |
+
# Input fields for user data
|
21 |
+
age = st.number_input('Age', min_value=18, max_value=100, value=30)
|
22 |
+
job = st.selectbox('Job', ['admin.', 'blue-collar', 'entrepreneur', 'housemaid', 'management', 'retired', 'self-employed', 'services', 'student', 'technician', 'unemployed', 'unknown'])
|
23 |
+
marital = st.selectbox('Marital Status', ['divorced', 'married', 'single', 'unknown'])
|
24 |
+
education = st.selectbox('Education', ['primary', 'secondary', 'tertiary', 'unknown'])
|
25 |
+
default = st.selectbox('Default', ['no', 'yes'])
|
26 |
+
balance = st.number_input('Balance', value=0)
|
27 |
+
housing = st.selectbox('Housing Loan', ['no', 'yes'])
|
28 |
+
loan = st.selectbox('Personal Loan', ['no', 'yes'])
|
29 |
+
contact = st.selectbox('Contact Communication Type', ['cellular', 'telephone', 'unknown'])
|
30 |
+
day = st.number_input('Last Contact Day', min_value=1, max_value=31, value=15)
|
31 |
+
month = st.selectbox('Last Contact Month', ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec'])
|
32 |
+
duration = st.number_input('Last Contact Duration', value=0)
|
33 |
+
campaign = st.number_input('Number of Contacts Performed', value=1)
|
34 |
+
pdays = st.number_input('Number of Days Passed After Last Contact', value=-1)
|
35 |
+
previous = st.number_input('Number of Contacts Performed Before', value=0)
|
36 |
+
poutcome = st.selectbox('Outcome of Previous Marketing Campaign', ['failure', 'nonexistent', 'success'])
|
37 |
+
|
38 |
+
# Create a dataframe from user input
|
39 |
+
data = {
|
40 |
+
'age': [age],
|
41 |
+
'job': [job],
|
42 |
+
'marital': [marital],
|
43 |
+
'education': [education],
|
44 |
+
'default': [default],
|
45 |
+
'balance': [balance],
|
46 |
+
'housing': [housing],
|
47 |
+
'loan': [loan],
|
48 |
+
'contact': [contact],
|
49 |
+
'day': [day],
|
50 |
+
'month': [month],
|
51 |
+
'duration': [duration],
|
52 |
+
'campaign': [campaign],
|
53 |
+
'pdays': [pdays],
|
54 |
+
'previous': [previous],
|
55 |
+
'poutcome': [poutcome]
|
56 |
+
}
|
57 |
+
|
58 |
+
input_df = pd.DataFrame(data)
|
59 |
+
|
60 |
+
# Predict the outcome
|
61 |
+
if st.button('Predict'):
|
62 |
+
prediction = model.predict(input_df)
|
63 |
+
if prediction[0] == 1:
|
64 |
+
st.success('The client is likely to subscribe for a term deposit.')
|
65 |
+
else:
|
66 |
+
st.error('The client is unlikely to subscribe for a term deposit.')
|
67 |
+
|
68 |
+
|