Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- y_column = "churn"
- X_columns = df_X_train.columns
- data_plot = df_X_train.copy()
- data_plot[y_column] = y_train
- plt.figure(figsize=(15, 30))
- for i_col in range(len(X_columns)):
- # Create subplot for each column
- plt.subplot(7, 3, i_col+1)
- # Get column and label values
- x_col = data_plot[X_columns[i_col]].values
- y_col = data_plot[y_column].values
- # Plot histograms
- bins = np.linspace(0, x_col.max(), 21)
- plt.hist(x_col[y_col == 0], bins=bins, color='r', alpha=0.5, label='0')
- plt.hist(x_col[y_col == 1], bins=bins, color='b', alpha=0.5, label='1')
- # Labels and legend
- plt.xlabel(X_columns[i_col])
- plt.ylabel('Counts')
- plt.legend(loc='best')
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement