Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- Dockerfile +5 -16
- app.py +61 -0
- requirements.txt +3 -3
Dockerfile
CHANGED
|
@@ -1,23 +1,12 @@
|
|
| 1 |
-
FROM ubuntu:22.04
|
| 2 |
|
| 3 |
-
|
| 4 |
|
| 5 |
-
|
| 6 |
-
build-essential \
|
| 7 |
-
curl \
|
| 8 |
-
software-properties-common \
|
| 9 |
-
git \
|
| 10 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
|
| 12 |
-
COPY
|
| 13 |
-
COPY src/ ./src/
|
| 14 |
|
| 15 |
-
RUN
|
| 16 |
-
apt-get install -y python3 python3-pip && \
|
| 17 |
-
pip3 install -r requirements.txt
|
| 18 |
|
| 19 |
EXPOSE 8501
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
|
|
|
|
|
|
|
| 1 |
|
| 2 |
+
FROM python:3.9-slim
|
| 3 |
|
| 4 |
+
WORKDIR /app
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
COPY ./app
|
|
|
|
| 7 |
|
| 8 |
+
RUN pip3 install -r requirements.txt
|
|
|
|
|
|
|
| 9 |
|
| 10 |
EXPOSE 8501
|
| 11 |
|
| 12 |
+
CMD ["streamlit","run","app.py","--server.port=8501","--server.address=0.0.0.0","--server.enableXsrfProtection=false"]
|
|
|
|
|
|
app.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import numpy as np
|
| 4 |
+
import requests
|
| 5 |
+
import streamlit as st
|
| 6 |
+
|
| 7 |
+
st.title('Customer Churn Prediction Frontend')
|
| 8 |
+
|
| 9 |
+
st.subheader('Online Prediction')
|
| 10 |
+
|
| 11 |
+
CustomerId=st.number_input('CustomerId',min_value=10000,max_value=99999999)
|
| 12 |
+
Surname=st.text_input('Surname')
|
| 13 |
+
CreditScore=st.number_input('CreditScore',min_value=300,max_value=900,value=450)
|
| 14 |
+
Geography=st.selectbox('Geography',['France','Spain','Germany'])
|
| 15 |
+
Age=st.number_input('Age',min_value=18,max_value=100,value=30)
|
| 16 |
+
Tenure=st.number_input('Tenure',min_value=0,max_value=10,value=5)
|
| 17 |
+
Balance=st.number_input('Balance',min_value=0.00,max_value=99999.99,value=97198.54)
|
| 18 |
+
NumOfProducts=st.number_input('NumOfProducts',min_value=1,max_value=4,value=2)
|
| 19 |
+
HasCrCard=st.selectbox('HasCrCard',['Yes','No'])
|
| 20 |
+
IsActiveMember=st.selectbox('IsActiveMember',['Yes','No'])
|
| 21 |
+
EstimatedSalary=st.number_input('EstimatedSalary',min_value=10.00,max_value=999999.99)
|
| 22 |
+
|
| 23 |
+
input_data={'CustomerId':CustomerId,
|
| 24 |
+
'Surname':Surname,
|
| 25 |
+
'CreditScore':CreditScore,
|
| 26 |
+
'Geography':Geography,
|
| 27 |
+
'Age':Age,
|
| 28 |
+
'Tenure':Tenure,
|
| 29 |
+
'Balance':Balance,
|
| 30 |
+
'NumOfProducts':NumOfProducts,
|
| 31 |
+
'HasCrCard':1 if HasCrCard=='Yes' else 0,
|
| 32 |
+
'IsActiveMember':1 if IsActiveMember=='Yes' else 0,
|
| 33 |
+
'EstimatedSalary':EstimatedSalary
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
if st.button('Predict'):
|
| 37 |
+
response=requests.post("https://siddhesh1981-CustomerChurnBackend.hf.space/Predict/Data",json=input_data)
|
| 38 |
+
if response.status_code==200:
|
| 39 |
+
result=response.json()
|
| 40 |
+
st.success(f"Based on the given input information the Customer with id {CustomerId} and Surname {Surname} is expected to {result['predict_label']}")
|
| 41 |
+
else:
|
| 42 |
+
st.error(response.text)
|
| 43 |
+
|
| 44 |
+
st.subheader('Batch Prediction')
|
| 45 |
+
|
| 46 |
+
file2=st.file_uploader('Upload a csv file',type=['csv'])
|
| 47 |
+
if file2 is not None:
|
| 48 |
+
if st.button('Predict Batch'):
|
| 49 |
+
response=requests.post("https://siddhesh1981-CustomerChurnBackend.hf.space/Predict/Batch",files={'file':file2})
|
| 50 |
+
if response.status_code==200:
|
| 51 |
+
result=response.json()
|
| 52 |
+
st.subheader('Batch Prediction Result')
|
| 53 |
+
st.success(result)
|
| 54 |
+
else:
|
| 55 |
+
st.error(response.text)
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
|
requirements.txt
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
streamlit
|
|
|
|
| 1 |
+
pandas==2.2.2
|
| 2 |
+
requests==2.28.1
|
| 3 |
+
streamlit==1.43.2
|