Spaces:
Sleeping
Sleeping
Upload eda.py
Browse files
eda.py
CHANGED
|
@@ -36,27 +36,6 @@ def app():
|
|
| 36 |
|
| 37 |
object_columns = df.select_dtypes(include=['object']).columns
|
| 38 |
numerical_columns = df.select_dtypes(exclude=['object']).columns
|
| 39 |
-
|
| 40 |
-
#plot all object columns to multiple boxplots based on index result of object_columns
|
| 41 |
-
for i in range(0,len(object_columns),2):
|
| 42 |
-
if len(object_columns) > i+1:
|
| 43 |
-
fig = plt.figure(figsize=(10,4))
|
| 44 |
-
plt.subplot(121)
|
| 45 |
-
sns.countplot(df[object_columns[i]])
|
| 46 |
-
plt.xticks(rotation=90)
|
| 47 |
-
plt.subplot(122)
|
| 48 |
-
sns.countplot(df[object_columns[i+1]])
|
| 49 |
-
plt.xticks(rotation=90)
|
| 50 |
-
plt.tight_layout()
|
| 51 |
-
# plt.show()
|
| 52 |
-
st.pyplot(fig)
|
| 53 |
-
|
| 54 |
-
else:
|
| 55 |
-
sns.countplot(df[object_columns[i]])
|
| 56 |
-
plt.xticks(rotation=90)
|
| 57 |
-
plt.show()
|
| 58 |
-
st.pyplot(fig)
|
| 59 |
-
|
| 60 |
|
| 61 |
# membuat barplot
|
| 62 |
# st.write('#### Plot AttackingWorkRate')
|
|
@@ -64,29 +43,40 @@ def app():
|
|
| 64 |
# sns.countplot(x='AttackingWorkRate', data=df)
|
| 65 |
# st.pyplot(fig)
|
| 66 |
|
| 67 |
-
# # membuat hist
|
| 68 |
-
# st.write('#### Histogram of Rating')
|
| 69 |
-
# fig = plt.figure(figsize=(15,5))
|
| 70 |
-
# sns.histplot(df['Overall'], bins=30, kde=True)
|
| 71 |
-
# st.pyplot(fig)
|
| 72 |
|
| 73 |
# # Membuat hist berdasarkan input
|
| 74 |
# st.write('#### Select histogram input')
|
| 75 |
|
| 76 |
-
#
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
|
|
|
| 83 |
fig = plt.figure(figsize=(15,5))
|
| 84 |
sns.histplot(df[option], bins=30, kde=True)
|
| 85 |
st.pyplot(fig)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
|
| 87 |
# Membuat plotly plot
|
| 88 |
-
st.write('#### Plotly Plot -
|
| 89 |
-
fig = px.scatter(df, x = '
|
| 90 |
st.plotly_chart(fig)
|
| 91 |
|
| 92 |
if __name__ == '__main__':
|
|
|
|
| 36 |
|
| 37 |
object_columns = df.select_dtypes(include=['object']).columns
|
| 38 |
numerical_columns = df.select_dtypes(exclude=['object']).columns
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
# membuat barplot
|
| 41 |
# st.write('#### Plot AttackingWorkRate')
|
|
|
|
| 43 |
# sns.countplot(x='AttackingWorkRate', data=df)
|
| 44 |
# st.pyplot(fig)
|
| 45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
# # Membuat hist berdasarkan input
|
| 48 |
# st.write('#### Select histogram input')
|
| 49 |
|
| 50 |
+
st.write('#### Plot Categorical Columns')
|
| 51 |
+
option_cat = st.selectbox('Select Column:', ('sex', 'education_level', 'martial_status'))
|
| 52 |
+
fig = plt.figure(figsize=(15,5))
|
| 53 |
+
sns.countplot(x=option_cat, data=df)
|
| 54 |
+
st.pyplot(fig)
|
| 55 |
+
|
| 56 |
+
st.write('#### Plot Numerical Columns')
|
| 57 |
+
option = st.selectbox('Select Column:', ('limit_balance', 'age'))
|
| 58 |
fig = plt.figure(figsize=(15,5))
|
| 59 |
sns.histplot(df[option], bins=30, kde=True)
|
| 60 |
st.pyplot(fig)
|
| 61 |
+
|
| 62 |
+
option_pay = st.selectbox('Select Column:', ('pay_0', 'pay_2', 'pay_3', 'pay_4', 'pay_5', 'pay_6'))
|
| 63 |
+
fig = plt.figure(figsize=(15,5))
|
| 64 |
+
sns.histplot(df[option_pay], bins=30, kde=True)
|
| 65 |
+
st.pyplot(fig)
|
| 66 |
+
|
| 67 |
+
option_bill_amt = st.selectbox('Select Column:', ('bill_amt_1', 'bill_amt_2', 'bill_amt_3', 'bill_amt_4', 'bill_amt_5', 'bill_amt_6'))
|
| 68 |
+
fig = plt.figure(figsize=(15,5))
|
| 69 |
+
sns.histplot(df[option_bill_amt], bins=30, kde=True)
|
| 70 |
+
st.pyplot(fig)
|
| 71 |
+
|
| 72 |
+
option_pay_amt = st.selectbox('Select Column:', ('pay_amt_1', 'pay_amt_2', 'pay_amt_3', 'pay_amt_4', 'pay_amt_5', 'pay_amt_6'))
|
| 73 |
+
fig = plt.figure(figsize=(15,5))
|
| 74 |
+
sns.histplot(df[option_bill_amt], bins=30, kde=True)
|
| 75 |
+
st.pyplot(fig)
|
| 76 |
|
| 77 |
# Membuat plotly plot
|
| 78 |
+
st.write('#### Plotly Plot - Age vs Limit Balance')
|
| 79 |
+
fig = px.scatter(df, x = 'age', y = 'limit_balance', hover_data = ['sex', 'default_payment_next_month'])
|
| 80 |
st.plotly_chart(fig)
|
| 81 |
|
| 82 |
if __name__ == '__main__':
|