File size: 23,115 Bytes
b8f05e2 |
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 |
import streamlit as st
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import plotly.express as px
from PIL import Image
def run() :
# Membuat Title
st.markdown("<h1 style='text-align: center; color: white;'>Exploratory Data Analysis</h1>", unsafe_allow_html=True)
st.write('Berikut adalah EDA dari setiap feature')
# Import DF
df_eda = pd.read_csv('employee_eda.csv')
# Membuat Sub Header Age
st.subheader('**EDA Feature Age**')
st.write('Dari visualisasi dibawah dapat disimpulkan bahwa :')
st.markdown('- Umur karyawan terpusat pada 25-30 tahun (2.350 karyawan/50.5%)')
st.markdown('- Karyawan yang paling banyak *resign* adalah karyawan dengan *range* umur 25-30 tahun (787 karyawan). Kemungkinan banyak pada *range* ini karena, karyawan paling banyak pada *range* umur tersebut ')
st.markdown('- Akan tetapi jika dilihat dari persentase *resign* pada setiap kelas, maka pada *range* umur 20-25 tahun memiliki persentase *resign* tertinggi. Kemudian pada *range* 25-40 tahun cenderung stabil dan persentase turun di angka 28% pada *range* 40-45 tahun')
# Membuat visualisasi Distribusi Age berdasarkan Bins
fig, ax =plt.subplots(1,2,figsize=(8,4))
sns.countplot(x='AgeBin', data=df_eda, palette="winter", ax=ax[0])
ax[0].set_xlabel("Employee Age", fontsize= 12)
ax[0].set_ylabel("# of Employee", fontsize= 12)
fig.suptitle('Distribusi Employee Age', fontsize=18, fontweight='bold')
ax[0].set_ylim(0,2500)
for p in ax[0].patches:
ax[0].annotate("%.0f"%(p.get_height()), (p.get_x() + p.get_width() / 2,
p.get_height()+45), ha='center', va='center',fontsize = 8)
df_eda['AgeBin'].value_counts().plot(kind='pie', autopct='%1.1f%%', textprops = {"fontsize":8})
ax[1].set_ylabel("% of Employee", fontsize= 12)
st.pyplot(fig)
# Membuat Visualisasi distribusi Age berdasarkan LeaveOrNot
col1, col2 = st.columns(2)
fig = plt.figure(figsize=(12,6))
ax = sns.countplot(data = df_eda, x = 'AgeBin', hue="LeaveOrNot", palette = 'winter', order = ['(20, 25]', '(25, 30]', '(30, 35]', '(35, 40]', '(40, 45]'])
plt.title('Distribusi Range Age', fontsize=18, fontweight='bold')
plt.xlabel("Range Age", fontsize= 12)
plt.ylabel("# of Employee", fontsize= 12)
ax.tick_params(axis="x", labelsize= 9.5)
plt.legend(fontsize=10,title='Klasifikasi LeaveOrNot', loc='upper right', labels=['Not Leave', 'Leave'])
for p in ax.patches:
ax.annotate("%.0f"%(p.get_height()), (p.get_x() + p.get_width() / 2,
p.get_height()+25), ha='center', va='center',fontsize = 11)
plt.ylim(0,1700)
col1.pyplot(fig)
#Visualisasi % Leave or Not dari setiap kelas
fig = plt.figure(figsize=(12,6))
ax = sns.barplot(x = 'AgeBin', y = 'LeaveOrNot', data = df_eda, palette = 'winter', order = ['(20, 25]', '(25, 30]', '(30, 35]', '(35, 40]', '(40, 45]'], errorbar=None)
plt.xlabel("Range Age", fontsize= 12)
plt.ylabel("% Leave", fontsize= 12)
plt.title('% Leave berdasarkan Age', fontsize=18, fontweight='bold')
plt.ylim(0,0.5)
for p in ax.patches:
ax.annotate("%.2f"%(p.get_height()), (p.get_x() + p.get_width() / 2,
p.get_height()+0.012), ha='center', va='center',fontsize = 11)
col2.pyplot(fig)
# Membuat Sub Header ExperienceInCurrentDomain
st.subheader('**EDA Feature ExperienceInCurrentDomain**')
st.write('Dari visualisasi dibawah dapat disimpulkan bahwa :')
st.markdown('- Pengalaman karyawan pada domain-nya terpusat pada 2 tahun (1.087 karyawan/23.4%)')
st.markdown('- Karyawan yang paling banyak *resign* adalah karyawan dengan *range* pengalaman 2 tahun (399 karyawan). Kemungkinan banyak pada *range* ini karena, karyawan paling banyak pada *range* pengalaman tersebut ')
st.markdown('- Akan tetapi jika dilihat dari persentase *resign* pada setiap kelas, maka persentase *resign* pada setiap kelas pengalaman tidak jauh berbeda (sekitar 30%)')
# Membuat visualisasi Distribusi ExperienceInCurrentDomain
fig, ax =plt.subplots(1,2,figsize=(8,4))
sns.countplot(x='ExperienceInCurrentDomain', data=df_eda, palette="winter", ax=ax[0])
ax[0].set_xlabel("Experience In Current Domain", fontsize= 12)
ax[0].set_ylabel("# of Employee", fontsize= 12)
fig.suptitle('Distribusi Experience In Current Domain', fontsize=18, fontweight='bold')
ax[0].set_ylim(0,1300)
for p in ax[0].patches:
ax[0].annotate("%.0f"%(p.get_height()), (p.get_x() + p.get_width() / 2,
p.get_height()+25), ha='center', va='center',fontsize = 8)
df_eda['ExperienceInCurrentDomain'].value_counts().plot(kind='pie', autopct='%1.1f%%', textprops = {"fontsize":8})
ax[1].set_ylabel("% of Employee", fontsize= 12)
st.pyplot(fig)
# Membuat Visualisasi distribusi ExperienceInCurrentDomain berdasarkan LeaveOrNot
col1, col2 = st.columns(2)
fig = plt.figure(figsize=(12,6))
ax = sns.countplot(data = df_eda, x = 'ExperienceInCurrentDomain', hue="LeaveOrNot", palette = 'winter')
plt.title('Distribusi Experience In Current Domain', fontsize=18, fontweight='bold')
plt.xlabel("Experience In Current Domain", fontsize= 12)
plt.ylabel("# of Employee", fontsize= 12)
ax.tick_params(axis="x", labelsize= 9.5)
plt.legend(fontsize=10,title='Klasifikasi LeaveOrNot', loc='upper right', labels=['Not Leave', 'Leave'])
for p in ax.patches:
ax.annotate("%.0f"%(p.get_height()), (p.get_x() + p.get_width() / 2,
p.get_height()+15), ha='center', va='center',fontsize = 11)
plt.ylim(0,800)
col1.pyplot(fig)
#Visualisasi % Leave or Not dari setiap kelas
fig = plt.figure(figsize=(12,6))
ax = sns.barplot(x = 'ExperienceInCurrentDomain', y = 'LeaveOrNot', data = df_eda, palette = 'winter', errorbar=None)
plt.xlabel("Experience In Current Domain", fontsize= 12)
plt.ylabel("% Leave", fontsize= 12)
plt.title('% Leave berdasarkan Experience In Current Domain', fontsize=18, fontweight='bold')
plt.ylim(0,0.5)
for p in ax.patches:
ax.annotate("%.2f"%(p.get_height()), (p.get_x() + p.get_width() / 2,
p.get_height()+0.012), ha='center', va='center',fontsize = 11)
col2.pyplot(fig)
# Membuat Sub Header JoiningYear
st.subheader('**EDA Feature JoiningYear**')
st.write('Dari visualisasi dibawah dapat disimpulkan bahwa :')
st.markdown('- Karyawan paling banyak bergabung pada tahun 2017 (1.108 karyawan/23.8%)')
st.markdown('- Karyawan yang paling banyak *resign* adalah karyawan yang bergabung pada tahun 2018 (362 karyawan)')
st.markdown('- Jika dilihat dari persentase *resign* pada setiap kelas, maka persentase *resign* untuk karyawan yang bergabung pada tahun 2018 lebih besar dari tahun lain-nya (99%)')
# Membuat visualisasi Distribusi JoiningYear
fig, ax =plt.subplots(1,2,figsize=(8,4))
sns.countplot(x='JoiningYear', data=df_eda, palette="winter", ax=ax[0])
ax[0].set_xlabel("JoiningYear", fontsize= 12)
ax[0].set_ylabel("# of Employee", fontsize= 12)
fig.suptitle('Distribusi JoiningYear', fontsize=18, fontweight='bold')
ax[0].set_ylim(0,1200)
for p in ax[0].patches:
ax[0].annotate("%.0f"%(p.get_height()), (p.get_x() + p.get_width() / 2,
p.get_height()+22), ha='center', va='center',fontsize = 8)
df_eda['JoiningYear'].value_counts().plot(kind='pie',autopct='%1.1f%%', textprops = {"fontsize":8})
ax[1].set_ylabel("% of Employee", fontsize= 12)
st.pyplot(fig)
#Visualisasi distribusi JoiningYear berdasarkan klasifikasi LeaveOrNot
col1, col2 = st.columns(2)
fig = plt.figure(figsize=(12,6))
ax = sns.countplot(data = df_eda, x = 'JoiningYear', hue="LeaveOrNot", palette = 'winter')
plt.xlabel("JoiningYear", fontsize= 12)
plt.ylabel("# of Employee", fontsize= 12)
plt.title('JoiningYear vs LeaveOrNot', fontsize=18, fontweight='bold')
plt.legend(fontsize=10,title='LeaveOrNot', loc='upper right', labels=['Not Leave', 'Leave'])
for p in ax.patches:
ax.annotate("%.0f"%(p.get_height()), (p.get_x() + p.get_width() / 2,
p.get_height()+15), ha='center', va='center',fontsize = 11)
plt.ylim(0,900)
col1.pyplot(fig)
#Visualisasi persentase Leave berdasarkan JoiningYear
fig = plt.figure(figsize=(12,6))
ax = sns.barplot(x = "JoiningYear", y = "LeaveOrNot", data = df_eda, palette = 'winter', errorbar= None)
plt.ylabel("% Leave", fontsize= 14)
plt.xlabel("JoiningYear", fontsize= 14)
plt.ylim(0,1.2)
plt.title('% Leave vs JoiningYear', fontsize=18, fontweight='bold')
for p in ax.patches:
ax.annotate("%.2f" %(p.get_height()), (p.get_x()+0.23, p.get_height()+0.01),fontsize=13)
col2.pyplot(fig)
# Membuat Sub Header Target LeaveOrNot
st.subheader('**EDA Feature LeaveOrNot**')
st.write('Dari visualisasi dibawah dapat disimpulkan bahwa :')
st.markdown('- Karyawan yang tidak *resign* lebih banyak dari pada karyawan yang *resign* dengan perbandingan 2 (65.6%) : 1 (34.4%)')
# Membuat visualisasi Distribusi LeaveOrNot
fig, ax =plt.subplots(1,2,figsize=(8,4))
sns.countplot(x='LeaveOrNot', data=df_eda, palette="winter", ax=ax[0])
ax[0].set_xlabel("LeaveOrNot", fontsize= 12)
ax[0].set_ylabel("# of Employee", fontsize= 12)
fig.suptitle('Distribusi LeaveOrNot', fontsize=18, fontweight='bold')
ax[0].set_ylim(0,3300)
plt.xlabel("Leave Or Not", fontsize= 12)
plt.ylabel("# of Employee", fontsize= 12)
ax[0].set_xticks([0,1], ['Not Leave', 'Leave'], fontsize = 11)
for p in ax[0].patches:
ax[0].annotate("%.0f"%(p.get_height()), (p.get_x() + p.get_width() / 2,
p.get_height()+55), ha='center', va='center',fontsize = 10)
df_eda['LeaveOrNot'].value_counts().plot(kind='pie', labels = ['Not Leave','Leave'],autopct='%1.1f%%', textprops = {"fontsize":8})
ax[1].set_ylabel("% of Employee", fontsize= 12)
st.pyplot(fig)
# Membuat Sub Header Education
st.subheader('**EDA Feature Education**')
st.write('Dari visualisasi dibawah dapat disimpulkan bahwa :')
st.markdown('- *Education* karyawan terbanyak adalah pada level *bachelors* (3.601 karyawan/77.4%)')
st.markdown('- Karyawan yang paling banyak *resign* adalah karyawan dengan level edukasi *bachelors* (1.129 karyawan). Kemungkinan banyak pada level ini karena, karyawan paling banyak pada level edukasi tersebut ')
st.markdown('- Akan tetapi jika dilihat dari persentase *resign* pada setiap kelas, maka persentase *resign* pada level edukasi *masters* lebih tinggi dari pada level edukasi lainnya (49%)')
# Membuat visualisasi Distribusi Education
fig, ax =plt.subplots(1,2,figsize=(8,4))
sns.countplot(x='Education', data=df_eda, palette="winter", ax=ax[0])
ax[0].set_xlabel("Education", fontsize= 12)
ax[0].set_ylabel("# of Employee", fontsize= 12)
fig.suptitle('Distribusi Education', fontsize=18, fontweight='bold')
ax[0].set_ylim(0,4000)
for p in ax[0].patches:
ax[0].annotate("%.0f"%(p.get_height()), (p.get_x() + p.get_width() / 2,
p.get_height()+70), ha='center', va='center',fontsize = 8)
df_eda['Education'].value_counts().plot(kind='pie',autopct='%1.1f%%', textprops = {"fontsize":8})
ax[1].set_ylabel("% of Employee", fontsize= 12)
st.pyplot(fig)
#Visualisasi distribusi Education berdasarkan klasifikasi LeaveOrNot
col1, col2 = st.columns(2)
fig = plt.figure(figsize=(12,6))
ax = sns.countplot(data = df_eda, x = 'Education', hue="LeaveOrNot", palette = 'winter')
plt.xlabel("Education", fontsize= 12)
plt.ylabel("# of Employee", fontsize= 12)
plt.title('Education vs LeaveOrNot', fontsize=18, fontweight='bold')
plt.legend(fontsize=10,title='LeaveOrNot', loc='upper right', labels=['Not Leave', 'Leave'])
for p in ax.patches:
ax.annotate("%.0f"%(p.get_height()), (p.get_x() + p.get_width() / 2,
p.get_height()+45), ha='center', va='center',fontsize = 11)
plt.ylim(0,3000)
col1.pyplot(fig)
#Visualisasi persentase Leave berdasarkan Education
fig = plt.figure(figsize=(12,6))
ax = sns.barplot(x = "Education", y = "LeaveOrNot", data = df_eda, palette = 'winter', errorbar= None)
plt.ylabel("% Leave", fontsize= 14)
plt.xlabel("Education", fontsize= 14)
plt.ylim(0,0.7)
plt.title('% Leave vs Education', fontsize=18, fontweight='bold')
for p in ax.patches:
ax.annotate("%.2f" %(p.get_height()), (p.get_x()+0.33, p.get_height()+0.01),fontsize=13)
col2.pyplot(fig)
# Membuat Sub Header City
st.subheader('**EDA Feature City**')
st.write('Dari visualisasi dibawah dapat disimpulkan bahwa :')
st.markdown('- Karyawan banyak yang bekerja pada kota Bangalore (2.228 karyawan/47.9%)')
st.markdown('- Karyawan yang paling banyak *resign* adalah karyawan yang bekerja di kota Pune (639 karyawan)')
st.markdown('- Jika dilihat dari persentase *resign* pada setiap kelas, maka persentase *resign* pada karyawan yang bekerja di kota Pune lebih tinggi dari pada karyawan yang bekerja di kota lainnya (50%)')
# Membuat visualisasi Distribusi City
fig, ax =plt.subplots(1,2,figsize=(8,4))
sns.countplot(x='City', data=df_eda, palette="winter", ax=ax[0])
ax[0].set_xlabel("City", fontsize= 12)
ax[0].set_ylabel("# of Employee", fontsize= 12)
fig.suptitle('Distribusi City', fontsize=18, fontweight='bold')
ax[0].set_ylim(0,2500)
for p in ax[0].patches:
ax[0].annotate("%.0f"%(p.get_height()), (p.get_x() + p.get_width() / 2,
p.get_height()+50), ha='center', va='center',fontsize = 8)
df_eda['City'].value_counts().plot(kind='pie',autopct='%1.1f%%', textprops = {"fontsize":8})
ax[1].set_ylabel("% of Employee", fontsize= 12)
st.pyplot(fig)
#Visualisasi distribusi City berdasarkan klasifikasi LeaveOrNot
col1, col2 = st.columns(2)
fig = plt.figure(figsize=(12,6))
ax = sns.countplot(data = df_eda, x = 'City', hue="LeaveOrNot", palette = 'winter')
plt.xlabel("City", fontsize= 12)
plt.ylabel("# of Employee", fontsize= 12)
plt.title('City vs LeaveOrNot', fontsize=18, fontweight='bold')
plt.legend(fontsize=10,title='LeaveOrNot', loc='upper right', labels=['Not Leave', 'Leave'])
for p in ax.patches:
ax.annotate("%.0f"%(p.get_height()), (p.get_x() + p.get_width() / 2,
p.get_height()+35), ha='center', va='center',fontsize = 11)
plt.ylim(0,2000)
col1.pyplot(fig)
#Visualisasi persentase Leave berdasarkan City
fig = plt.figure(figsize=(12,6))
ax = sns.barplot(x = "City", y = "LeaveOrNot", data = df_eda, palette = 'winter', errorbar= None)
plt.ylabel("% Leave", fontsize= 14)
plt.xlabel("City", fontsize= 14)
plt.ylim(0,0.7)
plt.title('% Leave vs City', fontsize=18, fontweight='bold')
for p in ax.patches:
ax.annotate("%.2f" %(p.get_height()), (p.get_x()+0.33, p.get_height()+0.01),fontsize=13)
col2.pyplot(fig)
# Membuat Sub Header Gender
st.subheader('**EDA Feature Gender**')
st.write('Dari visualisasi dibawah dapat disimpulkan bahwa :')
st.markdown('- Karyawan yang bekerja paling banyak memiliki *gender* pria (2.778 karyawan/59.7%)')
st.markdown('- Karyawan yang paling banyak *resign* adalah karyawan dengan *gender* wanita (884 karyawan)')
st.markdown('- Jika dilihat dari persentase *resign* pada setiap kelas, maka persentase *resign* pada *gender* wanita lebih banyak dari pada *gender* pria (47%)')
# Membuat visualisasi Distribusi Gender
fig, ax =plt.subplots(1,2,figsize=(8,4))
sns.countplot(x='Gender', data=df_eda, palette="winter", ax=ax[0])
ax[0].set_xlabel("Gender", fontsize= 12)
ax[0].set_ylabel("# of Employee", fontsize= 12)
fig.suptitle('Distribusi Gender', fontsize=18, fontweight='bold')
ax[0].set_ylim(0,3000)
for p in ax[0].patches:
ax[0].annotate("%.0f"%(p.get_height()), (p.get_x() + p.get_width() / 2,
p.get_height()+55), ha='center', va='center',fontsize = 8)
df_eda['Gender'].value_counts().plot(kind='pie',autopct='%1.1f%%', textprops = {"fontsize":8})
ax[1].set_ylabel("% of Employee", fontsize= 12)
st.pyplot(fig)
#Visualisasi distribusi Gender berdasarkan klasifikasi LeaveOrNot
col1, col2 = st.columns(2)
fig = plt.figure(figsize=(12,6))
ax = sns.countplot(data = df_eda, x = 'Gender', hue="LeaveOrNot", palette = 'winter')
plt.xlabel("Gender", fontsize= 12)
plt.ylabel("# of Employee", fontsize= 12)
plt.title('Gender vs LeaveOrNot', fontsize=18, fontweight='bold')
plt.legend(fontsize=10,title='LeaveOrNot', loc='upper right', labels=['Not Leave', 'Leave'])
for p in ax.patches:
ax.annotate("%.0f"%(p.get_height()), (p.get_x() + p.get_width() / 2,
p.get_height()+45), ha='center', va='center',fontsize = 11)
plt.ylim(0,2300)
col1.pyplot(fig)
#Visualisasi persentase Leave berdasarkan Gender
fig = plt.figure(figsize=(12,6))
ax = sns.barplot(x = "Gender", y = "LeaveOrNot", data = df_eda, palette = 'winter', errorbar= None)
plt.ylabel("% Leave", fontsize= 14)
plt.xlabel("Gender", fontsize= 14)
plt.ylim(0,0.6)
plt.title('% Leave vs Gender', fontsize=18, fontweight='bold')
for p in ax.patches:
ax.annotate("%.2f" %(p.get_height()), (p.get_x()+0.33, p.get_height()+0.01),fontsize=13)
col2.pyplot(fig)
# Membuat Sub Header EverBenched
st.subheader('**EDA Feature EverBenched**')
st.write('Dari visualisasi dibawha dapat disimpulkan bahwa :')
st.markdown('- Karyawan yang tidak pernah memegang *project* > 1 bulan lebih banyak dari yang pernah memegang *project* (4.175 karyawan/89.7%)')
st.markdown('- Karyawan yang paling banyak *resign* adalah karyawan yang tidak pernah memegang *project* > 1 bulan (1.383 karyawan). Kemungkinan banyak pada kelas ini karena, karyawan paling banyak pada kelas tersebut')
st.markdown('- Akan tetapi jika dilihat dari persentase *resign* pada setiap kelas, maka persentase *resign* pada karyawan yang pernah memegang *project* > 1 bulan lebih tinggi dari pada yang tidak pernah memegang *project* > 1 bulan (45%)')
# Membuat visualisasi Distribusi EverBenched
fig, ax =plt.subplots(1,2,figsize=(8,4))
sns.countplot(x='EverBenched', data=df_eda, palette="winter", ax=ax[0])
ax[0].set_xlabel("EverBenched", fontsize= 12)
ax[0].set_ylabel("# of Employee", fontsize= 12)
fig.suptitle('Distribusi EverBenched', fontsize=18, fontweight='bold')
ax[0].set_ylim(0,4600)
for p in ax[0].patches:
ax[0].annotate("%.0f"%(p.get_height()), (p.get_x() + p.get_width() / 2,
p.get_height()+70), ha='center', va='center',fontsize = 8)
df_eda['EverBenched'].value_counts().plot(kind='pie',autopct='%1.1f%%', textprops = {"fontsize":12})
ax[1].set_ylabel("% of Employee", fontsize= 12)
st.pyplot(fig)
#Visualisasi distribusi EverBenched berdasarkan klasifikasi LeaveOrNot
col1, col2 = st.columns(2)
fig = plt.figure(figsize=(12,6))
ax = sns.countplot(data = df_eda, x = 'EverBenched', hue="LeaveOrNot", palette = 'winter')
plt.xlabel("EverBenched", fontsize= 12)
plt.ylabel("# of Employee", fontsize= 12)
plt.title('EverBenched vs LeaveOrNot', fontsize=18, fontweight='bold')
plt.legend(fontsize=10,title='LeaveOrNot', loc='upper right', labels=['Not Leave', 'Leave'])
for p in ax.patches:
ax.annotate("%.0f"%(p.get_height()), (p.get_x() + p.get_width() / 2,
p.get_height()+45), ha='center', va='center',fontsize = 11)
plt.ylim(0,3100)
col1.pyplot(fig)
#Visualisasi persentase Leave berdasarkan EverBenched
fig = plt.figure(figsize=(12,6))
ax = sns.barplot(x = "EverBenched", y = "LeaveOrNot", data = df_eda, palette = 'winter', errorbar= None)
plt.ylabel("% Leave", fontsize= 14)
plt.xlabel("EverBenched", fontsize= 14)
plt.ylim(0,0.7)
plt.title('% Leave vs EverBenched', fontsize=18, fontweight='bold')
for p in ax.patches:
ax.annotate("%.2f" %(p.get_height()), (p.get_x()+0.33, p.get_height()+0.01),fontsize=13)
col2.pyplot(fig)
# Membuat Sub Header PaymentTier
st.subheader('**EDA Feature PaymentTier**')
st.write('Dari visualisasi dibawha dapat disimpulkan bahwa :')
st.markdown('- Karyawan banyak yang memiliki gaji dengan *tier* 3 (3.492 karyawan/75%)')
st.markdown('- Karyawan yang paling banyak *resign* adalah karyawan dengan gaji *tier* 3 (961 karyawan). Kemungkinan banyak pada kelas ini karena, karyawan paling banyak pada *tier* gaji tersebut')
st.markdown('- Akan tetapi jika dilihat dari persentase *resign* pada setiap kelas, maka persentase *resign* pada kelas gaji *tier* 2 lebih tinggi dari pada *tier* lainnya (60%)')
# Membuat visualisasi Distribusi PaymentTier
fig, ax =plt.subplots(1,2,figsize=(8,4))
sns.countplot(x='PaymentTier', data=df_eda, palette="winter", ax=ax[0])
ax[0].set_xlabel("PaymentTier", fontsize= 12)
ax[0].set_ylabel("# of Employee", fontsize= 12)
fig.suptitle('Distribusi PaymentTier', fontsize=18, fontweight='bold')
ax[0].set_ylim(0,4000)
for p in ax[0].patches:
ax[0].annotate("%.0f"%(p.get_height()), (p.get_x() + p.get_width() / 2,
p.get_height()+55), ha='center', va='center',fontsize = 8)
df_eda['PaymentTier'].value_counts().plot(kind='pie',autopct='%1.1f%%', textprops = {"fontsize":12})
ax[1].set_ylabel("% of Employee", fontsize= 12)
st.pyplot(fig)
#Visualisasi distribusi PaymentTier berdasarkan klasifikasi LeaveOrNot
col1, col2 = st.columns(2)
fig = plt.figure(figsize=(12,6))
ax = sns.countplot(data = df_eda, x = 'PaymentTier', hue="LeaveOrNot", palette = 'winter')
plt.xlabel("PaymentTier", fontsize= 12)
plt.ylabel("# of Employee", fontsize= 12)
plt.title('PaymentTier vs LeaveOrNot', fontsize=18, fontweight='bold')
plt.legend(fontsize=10,title='LeaveOrNot', loc='upper right', labels=['Not Leave', 'Leave'])
for p in ax.patches:
ax.annotate("%.0f"%(p.get_height()), (p.get_x() + p.get_width() / 2,
p.get_height()+45), ha='center', va='center',fontsize = 11)
plt.ylim(0,3000)
col1.pyplot(fig)
#Visualisasi persentase Leave berdasarkan PaymentTier
plt.figure(figsize=(12,6))
ax = sns.barplot(x = "PaymentTier", y = "LeaveOrNot", data = df_eda, palette = 'winter', errorbar= None)
plt.ylabel("% Leave", fontsize= 14)
plt.xlabel("PaymentTier", fontsize= 14)
plt.ylim(0,0.7)
plt.title('% Leave vs PaymentTier', fontsize=18, fontweight='bold')
for p in ax.patches:
ax.annotate("%.2f" %(p.get_height()), (p.get_x()+0.33, p.get_height()+0.01),fontsize=13)
col2.pyplot(fig)
if __name__ == '__main__':
run()
|