Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| import pandas as pd | |
| import numpy as np | |
| import plotly.express as px | |
| bank_df = pd.read_csv('./csv/BankChurners.csv') | |
| bank_df.drop(columns=["CLIENTNUM", | |
| "Naive_Bayes_Classifier_Attrition_Flag_Card_Category_Contacts_Count_12_mon_Dependent_count_Education_Level_Months_Inactive_12_mon_1", | |
| "Naive_Bayes_Classifier_Attrition_Flag_Card_Category_Contacts_Count_12_mon_Dependent_count_Education_Level_Months_Inactive_12_mon_2"], inplace=True) | |
| num_col = bank_df.select_dtypes(include=np.number).columns.tolist() | |
| cat_col = bank_df.select_dtypes(include=object).columns.tolist() | |
| cat_col.remove("Attrition_Flag") | |
| st.set_page_config( | |
| page_title="Customer Churn Classification", | |
| layout="wide", | |
| initial_sidebar_state="expanded", | |
| ) | |
| def distribution(): | |
| # distribution plot | |
| st.header("Data Distribution") | |
| attr_plot('Attrition_Flag') | |
| col1, col2 = st.columns(2) | |
| numerik = col1.selectbox(label="Select Features", options=num_col) | |
| hist_plot(numerik, col1) | |
| kategorik = col2.selectbox(label="Select Features", options=cat_col) | |
| count_plot(kategorik, col2) | |
| st.markdown(''' | |
| ''') | |
| def attr_plot(column): | |
| fig = px.histogram(bank_df, y=column, color="Attrition_Flag", title=f'Distribution of {column}') | |
| fig.update_layout(width=1200) | |
| st.plotly_chart(fig, use_container_width=True) | |
| def hist_plot(column, loc): | |
| fig = px.histogram(bank_df, x=column, color="Attrition_Flag", title=f'Histogram of {column}') | |
| loc.plotly_chart(fig) | |
| def count_plot(column, loc): | |
| fig = px.bar(bank_df, y=column, color="Attrition_Flag", title=f'Count Plot of {column}', orientation='h') | |
| loc.plotly_chart(fig) | |
| if __name__ == "__main__": | |
| distribution() | |