File size: 3,297 Bytes
1826e50 aa1b6a6 3dfe475 79ddfa4 d71218f df15fa6 b215ff0 1826e50 aa1b6a6 1826e50 4f3db09 1826e50 734f09c aa1b6a6 734f09c aa1b6a6 734f09c 1826e50 df15fa6 734f09c 1826e50 79ddfa4 1826e50 734f09c 1826e50 | 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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | # import streamlit as st
# from tensorflow import keras
# st.title('Credit Application Customer Prediction')
# model = keras.models.load_model('src/churn_model.h5')
# CreditScore=st.number_input('CreditScore', 1,10)
# Age=st.number_input('Age', 1,100)
# NumOfProducts=st.number_input('Number of Products', 1,100)
# if st.button('Tahmin et'):
# tahmin=model.predict([[CreditScore,Age,NumOfProducts]])
# tahmin=round(tahmin[0][0],2)
# st.success(f'YZ Has Exited the Bank: ${tahmin}')
# import streamlit as st
# import numpy as np
# from tensorflow.keras.models import load_model
# st.title('Credit Application Customer Prediction')
# # Load the model, ensuring the file path is correct
# try:
# model = load_model('src/churn_model.h5')
# except Exception as e:
# st.error(f"Error loading model: {e}")
# CreditScore = st.number_input('CreditScore', 1, 850)
# Age = st.number_input('Age', 1, 80)
# NumOfProducts = st.number_input('Number of Products', 1, 3)
# if st.button('Tahmin et'):
# input_data = np.array([[float(CreditScore), float(Age), float(NumOfProducts)]], dtype=np.float32)
# try:
# tahmin = model.predict(input_data)
# tahmin = round(tahmin[0][0], 2)
# st.success(f'YZ Has Exited the Bank: ${tahmin}')
# except Exception as e:
# st.error(f"Error making prediction: {e}")
import streamlit as st
import numpy as np
from tensorflow.keras.models import load_model
st.title('Credit Application Customer Prediction')
# Load the model
try:
model = load_model('src/churn_model.h5')
except Exception as e:
st.error(f"Error loading model: {e}")
# Input fields based on df1 columns (after encoding and feature engineering)
CreditScore = st.number_input('Credit Score', min_value=300, max_value=850)
Gender = st.selectbox('Gender', ['Male', 'Female'])
Age = st.number_input('Age', min_value=18, max_value=100)
Tenure = st.number_input('Tenure (Years)', min_value=0, max_value=10)
Balance = st.number_input('Balance', min_value=0.0)
NumOfProducts = st.number_input('Number of Products', min_value=1, max_value=4)
HasCrCard = st.selectbox('Has Credit Card', [0, 1])
IsActiveMember = st.selectbox('Is Active Member', [0, 1])
EstimatedSalary = st.number_input('Estimated Salary', min_value=0.0)
BalanceSalaryRatio = Balance / EstimatedSalary if EstimatedSalary > 0 else 0
TenureByAge = Tenure / Age if Age > 0 else 0
# One-hot encoded Geography fields
Geography_France = st.selectbox('Geography: France', [0, 1])
Geography_Spain = st.selectbox('Geography: Spain', [0, 1])
Geography_Germany = st.selectbox('Geography: Germany', [0, 1])
if st.button('Tahmin et'):
# Input order must match df1 columns used for model training
input_data = np.array([[
CreditScore,
1 if Gender == 'Male' else 0,
Age,
Tenure,
Balance,
NumOfProducts,
HasCrCard,
IsActiveMember,
EstimatedSalary,
BalanceSalaryRatio,
TenureByAge,
Geography_France,
Geography_Germany,
Geography_Spain
]], dtype=np.float32)
try:
tahmin = model.predict(input_data)
tahmin = round(tahmin[0][0], 2)
st.success(f'Prediction: {tahmin}')
except Exception as e:
st.error(f"Error making prediction: {e}") |