Skip to content

Instantly share code, notes, and snippets.

@therealnaveenkamal
Created July 22, 2021 05:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save therealnaveenkamal/0ce6a03a45370c24acd62394083cbac4 to your computer and use it in GitHub Desktop.
Save therealnaveenkamal/0ce6a03a45370c24acd62394083cbac4 to your computer and use it in GitHub Desktop.
This code is to visualize the balance between the positive and the negative values of each class
positive_freqs = np.mean(traingenerator.labels, axis = 0)
negative_freqs = 1 - positive_freqs
data = {
'Class': labels,
'Positive': positive_freqs,
'Negative':negative_freqs
}
X_axis = np.arange(len(labels))
fig, ax = plt.subplots(figsize=(10, 5))
ax.bar(X_axis-0.2, data['Positive'], width=0.4, color='b', label = "Positive")
ax.bar(X_axis+0.2, data['Negative'], width=0.4, color='r', label = 'Negative')
plt.xticks(X_axis, labels, rotation = 90)
plt.legend()
plt.figure(figsize=(20,15))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment