Spaces:
Sleeping
Sleeping
Delete app.py
Browse files
app.py
DELETED
|
@@ -1,51 +0,0 @@
|
|
| 1 |
-
import requests
|
| 2 |
-
import streamlit as st
|
| 3 |
-
import pandas as pd
|
| 4 |
-
|
| 5 |
-
st.title("Customer Churn Prediction")
|
| 6 |
-
|
| 7 |
-
# Input fields for customer data
|
| 8 |
-
CustomerID = st.number_input("Customer ID", min_value=10000000, max_value=99999999)
|
| 9 |
-
CreditScore = st.number_input("Credit Score (customer's credit score)", min_value=300, max_value=900, value=650)
|
| 10 |
-
Geography = st.selectbox("Geography (country where the customer resides)", ["France", "Germany", "Spain"])
|
| 11 |
-
Age = st.number_input("Age (customer's age in years)", min_value=18, max_value=100, value=30)
|
| 12 |
-
Tenure = st.number_input("Tenure (number of years the customer has been with the bank)", value=12)
|
| 13 |
-
Balance = st.number_input("Account Balance (customer’s account balance)", min_value=0.0, value=10000.0)
|
| 14 |
-
NumOfProducts = st.number_input("Number of Products (number of products the customer has with the bank)", min_value=1, value=1)
|
| 15 |
-
HasCrCard = st.selectbox("Has Credit Card?", ["Yes", "No"])
|
| 16 |
-
IsActiveMember = st.selectbox("Is Active Member?", ["Yes", "No"])
|
| 17 |
-
EstimatedSalary = st.number_input("Estimated Salary (customer’s estimated salary)", min_value=0.0, value=50000.0)
|
| 18 |
-
|
| 19 |
-
customer_data = {
|
| 20 |
-
'CreditScore': CreditScore,
|
| 21 |
-
'Geography': Geography,
|
| 22 |
-
'Age': Age,
|
| 23 |
-
'Tenure': Tenure,
|
| 24 |
-
'Balance': Balance,
|
| 25 |
-
'NumOfProducts': NumOfProducts,
|
| 26 |
-
'HasCrCard': 1 if HasCrCard == "Yes" else 0,
|
| 27 |
-
'IsActiveMember': 1 if IsActiveMember == "Yes" else 0,
|
| 28 |
-
'EstimatedSalary': EstimatedSalary
|
| 29 |
-
}
|
| 30 |
-
|
| 31 |
-
if st.button("Predict", type='primary'):
|
| 32 |
-
response = requests.post("https://praneeth232-demo-cont.hf.space/v1/customer", json=customer_data)
|
| 33 |
-
if response.status_code == 200:
|
| 34 |
-
result = response.json()
|
| 35 |
-
churn_prediction = result["Churn expected?"] # Extract only the value
|
| 36 |
-
st.write(f"Based on the information provided, the customer with ID {CustomerID} is likely to {churn_prediction}.")
|
| 37 |
-
else:
|
| 38 |
-
st.error("Error in API request")
|
| 39 |
-
|
| 40 |
-
# Batch Prediction
|
| 41 |
-
st.subheader("Batch Prediction")
|
| 42 |
-
file = st.file_uploader("Upload CSV file", type=["csv"])
|
| 43 |
-
if file is not None:
|
| 44 |
-
if st.button("Predict for Batch", type='primary'):
|
| 45 |
-
response = requests.post("https://praneeth232-demo-cont.hf.space/v1/customerbatch", files={"file": file})
|
| 46 |
-
if response.status_code == 200:
|
| 47 |
-
result = response.json()
|
| 48 |
-
st.header("Batch Prediction Results")
|
| 49 |
-
st.write(result)
|
| 50 |
-
else:
|
| 51 |
-
st.error("Error in API request")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|