Spaces:
Runtime error
Runtime error
| 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", ['Fiber optic', 'DSL', '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", ['Two year', 'One year', 'Month-to-month']) | |
| PaperlessBilling = st.sidebar.selectbox("PaperlessBilling", ['No', 'Yes']) | |
| PaymentMethod = st.selectbox("PaymentMethod", ['Credit card (automatic)', 'Electronic check', 'Mailed check', 'Bank transfer (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) |