Enoch1359 commited on
Commit
ca2c5a0
·
verified ·
1 Parent(s): 5b2db9d

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. Dockerfile +7 -14
  2. app.py +37 -0
  3. model.joblib +3 -0
  4. requirement.txt +6 -0
Dockerfile CHANGED
@@ -1,21 +1,14 @@
 
1
  FROM python:3.9-slim
2
 
 
3
  WORKDIR /app
4
 
5
- RUN apt-get update && apt-get install -y \
6
- build-essential \
7
- curl \
8
- software-properties-common \
9
- git \
10
- && rm -rf /var/lib/apt/lists/*
11
-
12
- COPY requirements.txt ./
13
- COPY src/ ./src/
14
 
 
15
  RUN pip3 install -r requirements.txt
16
 
17
- EXPOSE 8501
18
-
19
- HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
20
-
21
- ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
1
+ # Use a minimal base image with Python 3.9 installed
2
  FROM python:3.9-slim
3
 
4
+ # Set the working directory inside the container to /app
5
  WORKDIR /app
6
 
7
+ # Copy all files from the current directory on the host to the container's /app directory
8
+ COPY . .
 
 
 
 
 
 
 
9
 
10
+ # Install Python dependencies listed in requirements.txt
11
  RUN pip3 install -r requirements.txt
12
 
13
+ # Define the command to run the Streamlit app on port 8501 and make it accessible externally
14
+ CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false"]
 
 
 
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import joblib as jb
4
+
5
+ def load_model():
6
+ return jb.load('deploy_fm/model.joblib')
7
+ mm2=load_model()
8
+
9
+ st.title('custo_churn')
10
+ st.write('enter the details')
11
+ cred=st.number_input('credit score',min_value=300,max_value=900,value=650)
12
+ geo=st.selectbox('geography',['france','germany','spain'])
13
+ Age = st.number_input("Age (customer's age in years)", min_value=18, max_value=100, value=30)
14
+ Tenure = st.number_input("Tenure (number of years the customer has been with the bank)", value=12)
15
+ Balance = st.number_input("Account Balance (customer’s account balance)", min_value=0.0, value=10000.0)
16
+ NumOfProducts = st.number_input("Number of Products (number of products the customer has with the bank)", min_value=1, value=1)
17
+ HasCrCard = st.selectbox("Has Credit Card?", ["Yes", "No"])
18
+ IsActiveMember = st.selectbox("Is Active Member?", ["Yes", "No"])
19
+ EstimatedSalary = st.number_input("Estimated Salary (customer’s estimated salary)", min_value=0.0, value=50000.0)
20
+ input_data = pd.DataFrame([{
21
+ 'CreditScore': cred,
22
+ 'Geography': geo,
23
+ 'Age': Age,
24
+ 'Tenure': Tenure,
25
+ 'Balance': Balance,
26
+ 'NumOfProducts': NumOfProducts,
27
+ 'HasCrCard': 1 if HasCrCard == "Yes" else 0,
28
+ 'IsActiveMember': 1 if IsActiveMember == "Yes" else 0,
29
+ 'EstimatedSalary': EstimatedSalary
30
+ }])
31
+
32
+ ct=0.45
33
+ if st.button('predict'):
34
+ prediction_proba=mm2.predict_proba(input_data)[0,1]
35
+ prediction=(prediction_proba>=ct).astype(int)
36
+ result='churn' if prediction==1 else 'not churn'
37
+ st.write(f'based on the information provided the customer is likely to {result}')
model.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4797c9b09d9ff6e5c624824395fd70c80e615aea1497ac972b744b81fe724799
3
+ size 49311
requirement.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ pandas==2.2.2
2
+ numpy==2.0.2
3
+ scikit-learn==1.6.1
4
+ xgboost==2.1.4
5
+ joblib==1.5.1
6
+ streamlit==1.46.0