Created
December 23, 2020 11:35
-
-
Save suhaskv/fec0977939c71c9af504f799ae602168 to your computer and use it in GitHub Desktop.
VSB Power Line Blog - Get the distribution of the target data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
splot = sns.countplot(x='target', data=metadata_train) | |
# https://github.com/mwaskom/seaborn/issues/1582 | |
for ind, p in enumerate(splot.patches): | |
percent = np.round((metadata_train[metadata_train['target']==ind].shape[0]/metadata_train['target'].shape[0])*100, 2) | |
splot.annotate(str(metadata_train[metadata_train['target']==ind].shape[0]) + f" ({percent}%)", | |
(p.get_x()+p.get_width()/2, p.get_height())) | |
plt.title("Distribution of target classes") | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment