Skip to content

Instantly share code, notes, and snippets.

@kusal1990
Created June 2, 2022 18:07
Show Gist options
  • Save kusal1990/db711a99dc3f8ec1d64d165431f0e5cb to your computer and use it in GitHub Desktop.
Save kusal1990/db711a99dc3f8ec1d64d165431f0e5cb to your computer and use it in GitHub Desktop.
subplot = sns.countplot(x='target', data=df_metadata_train)
# https://github.com/mwaskom/seaborn/issues/1582
for i,j in enumerate(subplot.patches):
percent = np.round((df_metadata_train[df_metadata_train['target']==i].shape[0]/df_metadata_train['target'].shape[0])*100, 2)
subplot.annotate(str(df_metadata_train[df_metadata_train['target']==i].shape[0]) + f" ({percent}%)",
(j.get_x()+j.get_width()/2, j.get_height()))
plt.title("Distribution of target classes")
plt.show()
@kusal1990
Copy link
Author

ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment