Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. %matplotlib inline
  2. fig = plt.figure(figsize=(25, 25))
  3. fig.subplots(nrows=7, ncols=2)
  4. for feat_i in range(number_of_features): #For each feature, we have a new subplot
  5.     ax = plt.subplot(7,2, feat_i+1)
  6.     plt.title(feature_names[feat_i])
  7.     sns.distplot(X[:,feat_i]) #Once we have a specific feature, we draw the histogram of the feature's data (X[:,i] means we get the i'th column of X)
  8.     for class_i in range(number_of_classes): #After that we draw the within-class histograms of the same feature
  9.         sns.distplot(X[y == class_i,feat_i], color=colors[class_i], label=target_names[class_i]) # (X[y==c,i] means we get the i'th column of X where the class in the same row in y is equal to c
  10.     plt.legend()
  11. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement