mymodels / app.py
Enoch1359's picture
Update app.py
c0cdeb9 verified
import streamlit as st
import pandas as pd
import joblib as jb
def load_model():
return jb.load('model.joblib')
mm2=load_model()
st.title('custo_churn')
st.write('enter the details')
cred=st.number_input('credit score',min_value=300,max_value=900,value=650)
geo=st.selectbox('geography',['France','Germany','Spain'])
Age = st.number_input("Age (customer's age in years)", min_value=18, max_value=100, value=30)
Tenure = st.number_input("Tenure (number of years the customer has been with the bank)", value=12)
Balance = st.number_input("Account Balance (customer’s account balance)", min_value=0.0, value=10000.0)
NumOfProducts = st.number_input("Number of Products (number of products the customer has with the bank)", min_value=1, value=1)
HasCrCard = st.selectbox("Has Credit Card?", ["Yes", "No"])
IsActiveMember = st.selectbox("Is Active Member?", ["Yes", "No"])
EstimatedSalary = st.number_input("Estimated Salary (customer’s estimated salary)", min_value=0.0, value=50000.0)
input_data = pd.DataFrame([{
'CreditScore': cred,
'Geography': geo,
'Age': Age,
'Tenure': Tenure,
'Balance': Balance,
'NumOfProducts': NumOfProducts,
'HasCrCard': 1 if HasCrCard == "Yes" else 0,
'IsActiveMember': 1 if IsActiveMember == "Yes" else 0,
'EstimatedSalary': EstimatedSalary
}])
ct=0.45
if st.button('predict'):
prediction_proba=mm2.predict_proba(input_data)[0,1]
prediction=(prediction_proba>=ct).astype(int)
result='churn' if prediction==1 else 'not churn'
st.write(f'based on the information provided the customer is likely to {result}')