File size: 2,448 Bytes
1167c5a
 
 
 
 
 
 
 
 
a57647d
1167c5a
 
a57647d
1167c5a
 
a57647d
1167c5a
a57647d
1167c5a
a57647d
1167c5a
 
a57647d
1167c5a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40f117a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import streamlit as st
import numpy as np
import pandas as pd
import joblib

model = joblib.load('Churn_PredCls.joblib')

gender = st.selectbox("Choose sex", ['Male', 'Female'])
SeniorCitizen = st.sidebar.selectbox("SeniorCitizen", ['Yes', 'No'])
Partner = st.sidebar.selectbox("Does he/she have partner?", ['No', 'Yes'])
Dependents = st.sidebar.selectbox("Dependents", ['Yes', 'No'])
tenure = st.slider("Choose tenure", 0, 100)
PhoneService = st.sidebar.selectbox("PhoneService", ['No', 'Yes'])
MultipleLines = st.sidebar.selectbox("MultipleLines", ['Yes', 'No'])
InternetService = st.selectbox("InternetService", ['DSL', 'Fiber optic', 'No'])
OnlineSecurity = st.sidebar.selectbox("OnlineSecurity", ['No', 'Yes'])
OnlineBackup = st.sidebar.selectbox("OnlineBackup", ['Yes', 'No'])
DeviceProtection = st.sidebar.selectbox("DeviceProtection", ['No', 'Yes'])
TechSupport = st.sidebar.selectbox("TechSupport", ['Yes', 'No'])
StreamingTV = st.sidebar.selectbox("StreamingTV", ['No', 'Yes'])
StreamingMovies = st.sidebar.selectbox("StreamingMovies", ['Yes', 'No'])
Contract = st.selectbox("Contract", ['Month-to-month', 'One year', 'Two year'])
PaperlessBilling = st.sidebar.selectbox("PaperlessBilling", ['No', 'Yes'])
PaymentMethod = st.selectbox("PaymentMethod", ['Electronic check', 'Mailed check', 'Bank transfer (automatic)', 'Credit card (automatic)'])
MonthlyCharges = st.slider("MonthlyCharges", 0, 1000)
TotalCharges = st.slider("TotalCharges", 0, 10000)

columns =  ['gender', 'SeniorCitizen', 'Partner', 'Dependents', 'tenure',
       'PhoneService', 'MultipleLines', 'InternetService', 'OnlineSecurity',
       'OnlineBackup', 'DeviceProtection', 'TechSupport', 'StreamingTV',
       'StreamingMovies', 'Contract', 'PaperlessBilling', 'PaymentMethod',
       'MonthlyCharges', 'TotalCharges']

rows = [gender, SeniorCitizen, Partner, Dependents, tenure,
       PhoneService, MultipleLines, InternetService, OnlineSecurity, OnlineBackup,
       DeviceProtection, TechSupport, StreamingTV, StreamingMovies, Contract,
       PaperlessBilling, PaymentMethod, MonthlyCharges, TotalCharges]

def predict():
    row = np.array(rows)
    X = pd.DataFrame([row], columns = columns)
    prediction = model.predict(X)
    if prediction[0] == 1:
        st.success('She/He will remain among the customers :thumbsup:')
    else:
        st.error('She/He will not remain among the customers :thumbsup:')

trigger = st.button('Predict', on_click=predict)