siddhesh1981's picture
Upload folder using huggingface_hub
1a2eaa6 verified
import pandas as pd
import numpy as np
import requests
import streamlit as st
st.title('Customer Churn Prediction Frontend')
st.subheader('Online Prediction')
CustomerId=st.number_input('CustomerId',min_value=10000,max_value=99999999)
Surname=st.text_input('Surname')
CreditScore=st.number_input('CreditScore',min_value=300,max_value=900,value=450)
Geography=st.selectbox('Geography',['France','Spain','Germany'])
Age=st.number_input('Age',min_value=18,max_value=100,value=30)
Tenure=st.number_input('Tenure',min_value=0,max_value=10,value=5)
Balance=st.number_input('Balance',min_value=0.00,max_value=99999.99,value=97198.54)
NumOfProducts=st.number_input('NumOfProducts',min_value=1,max_value=4,value=2)
HasCrCard=st.selectbox('HasCrCard',['Yes','No'])
IsActiveMember=st.selectbox('IsActiveMember',['Yes','No'])
EstimatedSalary=st.number_input('EstimatedSalary',min_value=10.00,max_value=999999.99)
input_data={'CreditScore':CreditScore,
'Geography':Geography,
'Age':Age,
'Tenure':Tenure,
'Balance':Balance,
'NumOfProducts':NumOfProducts,
'HasCrCard':1 if HasCrCard=='Yes' else 0,
'IsActiveMember':1 if IsActiveMember=='Yes' else 0,
'EstimatedSalary':EstimatedSalary
}
if st.button('Predict'):
response=requests.post("https://siddhesh1981-CustomerChurnBackend.hf.space/Predict/Data",json=input_data)
if response.status_code==200:
result=response.json()
st.success(f"Based on the given input information the Customer with id {CustomerId} and Surname {Surname} is expected to {result['predict_label']}")
else:
st.error(response.text)
st.subheader('Batch Prediction')
file2=st.file_uploader('Upload a csv file',type=['csv'])
if file2 is not None:
if st.button('Predict Batch'):
response=requests.post("https://siddhesh1981-CustomerChurnBackend.hf.space/Predict/Batch",files={'file':file2})
if response.status_code==200:
result=response.json()
st.subheader('Batch Prediction Result')
st.success(result)
else:
st.error(response.text)