Jason
commited on
Commit
·
e781a1b
1
Parent(s):
0f8ef4e
add feature TelkomselProactive
Browse files- app.py +5 -2
- config.ini +2 -2
- helpers/__pycache__/plot.cpython-310.pyc +0 -0
- helpers/__pycache__/query.cpython-310.pyc +0 -0
- helpers/query.py +9 -0
- proactive.py +28 -0
app.py
CHANGED
|
@@ -2,13 +2,16 @@ import streamlit as st
|
|
| 2 |
|
| 3 |
import eda
|
| 4 |
import predictor
|
|
|
|
| 5 |
|
| 6 |
navigation = st.sidebar.selectbox(
|
| 7 |
label='Pilih Halaman',
|
| 8 |
-
options=('EDA', 'Predictor')
|
| 9 |
)
|
| 10 |
|
| 11 |
if navigation == 'EDA':
|
| 12 |
eda.run()
|
| 13 |
elif navigation == 'Predictor':
|
| 14 |
-
predictor.run()
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
import eda
|
| 4 |
import predictor
|
| 5 |
+
import proactive
|
| 6 |
|
| 7 |
navigation = st.sidebar.selectbox(
|
| 8 |
label='Pilih Halaman',
|
| 9 |
+
options=('EDA', 'Predictor', 'Proactive')
|
| 10 |
)
|
| 11 |
|
| 12 |
if navigation == 'EDA':
|
| 13 |
eda.run()
|
| 14 |
elif navigation == 'Predictor':
|
| 15 |
+
predictor.run()
|
| 16 |
+
elif navigation == 'Proactive':
|
| 17 |
+
proactive.run()
|
config.ini
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
[DEFAULT]
|
| 2 |
-
production =
|
| 3 |
|
| 4 |
[DEVELOPMENT]
|
| 5 |
-
URL = http://127.0.0.1:5000
|
| 6 |
|
| 7 |
[PRODUCTION]
|
| 8 |
URL = https://backend-telco-churn-kidfrom.koyeb.app
|
|
|
|
| 1 |
[DEFAULT]
|
| 2 |
+
production = False
|
| 3 |
|
| 4 |
[DEVELOPMENT]
|
| 5 |
+
URL = http://127.0.0.1:5000
|
| 6 |
|
| 7 |
[PRODUCTION]
|
| 8 |
URL = https://backend-telco-churn-kidfrom.koyeb.app
|
helpers/__pycache__/plot.cpython-310.pyc
DELETED
|
Binary file (1.68 kB)
|
|
|
helpers/__pycache__/query.cpython-310.pyc
DELETED
|
Binary file (529 Bytes)
|
|
|
helpers/query.py
CHANGED
|
@@ -13,6 +13,15 @@ else:
|
|
| 13 |
def fetch_all_data() -> pd.DataFrame:
|
| 14 |
r = requests.get(URL+"/query")
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
if r.status_code == 200:
|
| 17 |
res = r.json()
|
| 18 |
return pd.DataFrame(res)
|
|
|
|
| 13 |
def fetch_all_data() -> pd.DataFrame:
|
| 14 |
r = requests.get(URL+"/query")
|
| 15 |
|
| 16 |
+
if r.status_code == 200:
|
| 17 |
+
res = r.json()
|
| 18 |
+
return pd.DataFrame(res)
|
| 19 |
+
else:
|
| 20 |
+
return ('Error with status code ', str(r.status_code))
|
| 21 |
+
|
| 22 |
+
def proactive() -> pd.DataFrame:
|
| 23 |
+
r = requests.get(URL+"/proactive")
|
| 24 |
+
|
| 25 |
if r.status_code == 200:
|
| 26 |
res = r.json()
|
| 27 |
return pd.DataFrame(res)
|
proactive.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
from helpers import query
|
| 4 |
+
|
| 5 |
+
def run():
|
| 6 |
+
st.title('TelkomselProactive')
|
| 7 |
+
|
| 8 |
+
st.write("Duly noted: The data set is not real.")
|
| 9 |
+
|
| 10 |
+
st.markdown(
|
| 11 |
+
"""
|
| 12 |
+
Telkomsel employee can use this page to get a list of customer that is going to churn.
|
| 13 |
+
|
| 14 |
+
By having this list, Telkomsel will be able to proactively go to the customer, that is about to churn, and prevent that said customer from opting out of the Telco services.
|
| 15 |
+
|
| 16 |
+
The list is generated with this logic:
|
| 17 |
+
1. We don't have the future data set (the ones without Churn column).
|
| 18 |
+
2. So just imagine that the data set we are using is connected to the database. Thus, we use the latest data.
|
| 19 |
+
3. The back end fetch 10 sample and will predict whether a customer will churn or not.
|
| 20 |
+
4. The back end will only return the list of customer that will churn.
|
| 21 |
+
"""
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
if st.button(label='Fetch new list'):
|
| 25 |
+
df = query.proactive()
|
| 26 |
+
st.dataframe(df)
|
| 27 |
+
|
| 28 |
+
|