innoefawwaz1 commited on
Commit
705865d
β€’
1 Parent(s): 52e7686

added python app file and requirements

Browse files
Files changed (3) hide show
  1. README.md +5 -5
  2. app.py +60 -0
  3. requirements.txt +6 -0
README.md CHANGED
@@ -1,10 +1,10 @@
1
  ---
2
- title: P2m1 Frontend Deployment
3
- emoji: 🏒
4
- colorFrom: green
5
- colorTo: gray
6
  sdk: streamlit
7
- sdk_version: 1.15.2
8
  app_file: app.py
9
  pinned: false
10
  ---
 
1
  ---
2
+ title: Milestone1 Deploy
3
+ emoji: πŸŒ–
4
+ colorFrom: gray
5
+ colorTo: purple
6
  sdk: streamlit
7
+ sdk_version: 1.10.0
8
  app_file: app.py
9
  pinned: false
10
  ---
app.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+
4
+ # Give the Name of the Application
5
+ st.title('Prediction Churn of Customer')
6
+
7
+ # Create Submit Form
8
+ with st.form(key='form_parameters'):
9
+ g = st.sidebar.selectbox(label='Gender', options=['Female', 'Male'])
10
+ s = st.sidebar.selectbox(label='SeniorCitizen', options=[0,1])
11
+ p = st.sidebar.selectbox(label='Partner', options=['No', 'Yes'])
12
+ d = st.sidebar.selectbox(label='Dependents', options=['No', 'Yes'])
13
+ t = st.number_input('Tenure', min_value=0, step=1, max_value=73)
14
+ ps = st.sidebar.selectbox(label='PhoneService', options=['No', 'Yes'])
15
+ ml = st.sidebar.selectbox(label='MultipleLines', options=['No phone service','No','Yes'])
16
+ ins = st.sidebar.selectbox(label='InternetService', options=['No','DSL','Fiber optic'])
17
+ ons = st.sidebar.selectbox(label='OnlineSecurity', options=['No internet service','No','Yes'])
18
+ onb = st.sidebar.selectbox(label='OnlineBackup', options=['No internet service','No','Yes'])
19
+ dp = st.sidebar.selectbox(label='DeviceProtection', options=['No internet service','No','Yes'])
20
+ ts = st.sidebar.selectbox(label='TechSupport', options=['No internet service','No','Yes'])
21
+ stv = st.sidebar.selectbox(label='StreamingTV', options=['No internet service','No','Yes'])
22
+ sm = st.sidebar.selectbox(label='StreamingMovies', options=['No internet service','No','Yes'])
23
+ con = st.sidebar.selectbox(label='Contract', options=['Month-to-month','One year','Two year'])
24
+ pb = st.sidebar.selectbox(label='PaperlessBilling', options=['No', 'Yes'])
25
+ pm = st.sidebar.selectbox(label='PaymentMethod', options=['Electronic check','Mailed check','Bank transfer (automatic)','Credit card (automatic)'])
26
+ mc = st.number_input('MonthlyCharges', min_value=18.25, step=0.05,max_value=118.75)
27
+ tc = st.number_input('TotalCharges', min_value=18.8, step=0.02,max_value=8684.8)
28
+
29
+ submitted = st.form_submit_button('Predict')
30
+
31
+ # inference
32
+ if submitted:
33
+ URL = 'https://milestone1-innoefawwaz.koyeb.app/predict'
34
+ param = {'gender': g,
35
+ 'SeniorCitizen': s,
36
+ 'Partner': p,
37
+ 'Dependents': d,
38
+ 'tenure': t,
39
+ 'PhoneService': ps,
40
+ 'MultipleLines': ml,
41
+ 'InternetService': ins,
42
+ 'OnlineSecurity': ons,
43
+ 'OnlineBackup': onb,
44
+ 'DeviceProtection': dp,
45
+ 'TechSupport': ts,
46
+ 'StreamingTV': stv,
47
+ 'StreamingMovies':sm,
48
+ 'Contract': con,
49
+ 'PaperlessBilling': pb,
50
+ 'PaymentMethod': pm,
51
+ 'MonthlyCharges': mc,
52
+ 'TotalCharges': tc}
53
+
54
+ r = requests.post(URL, json=param)
55
+ if r.status_code == 200:
56
+ res = r.json()
57
+ st.title('Telco Customer Churn is {}'.format(res['label_names']))
58
+ else:
59
+ st.title("Unexpected Error")
60
+ st.write(r.status_code)
requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ pandas
2
+ scikit-learn==1.0.2
3
+ numpy
4
+ flask
5
+ gunicorn
6
+ tensorflow-cpu