Created a correlation matrix by applying the function .corr() on the dataframe.
Used Seaborn Library to plot a heatmap of the correlation matrix. "Viridis" is used to define the color palette of the graph.
figsize(20,8) is used to define the size of the figure.
Created a confusion matrix by importing confusion matrix library from sklearn.metrics
Plotted the graph of confusion matrix
plt.imshow(cm, interpolation='nearest', cmap=plt.cm.Blues): This line displays the confusion matrix (cm) as an image using plt.imshow.
plt.colorbar(label='Number of samples'): This line adds a colorbar to the plot using plt.colorbar.
plt.xticks(np.arange(len(np.unique(y_test))), np.unique(y_test)): This line sets the tick labels and positions for the x-axis (predicted class) using plt.xticks.
np.arange(len(np.unique(y_test))) generates an array of indices corresponding to the unique values in y_test (which likely represent the predicted classes).
np.unique(y_test) gets the unique class labels from y_test. These labels are used as tick labels for the x-axis.
plt.yticks(np.arange(len(np.unique(preds))), np.unique(preds)): This line sets the tick labels and positions for the y-axis (true class) using plt.yticks. Similar to the x-axis, it uses np.unique(preds) (likely representing the true classes) to set the tick labels.
plt.text(0, 0, str(cm[0, 0]), ha='center', va='center', fontsize=12, color='white'): This line adds text to the top-left corner (cell (0, 0)) of the confusion matrix plot using plt.text.
Created a correlation matrix by applying the function .corr() on the dataframe.
Used Seaborn Library to plot a heatmap of the correlation matrix. "Viridis" is used to define the color palette of the graph.
figsize(20,8) is used to define the size of the figure.
Created a confusion matrix by importing confusion matrix library from sklearn.metrics
Plotted the graph of confusion matrix
plt.imshow(cm, interpolation='nearest', cmap=plt.cm.Blues): This line displays the confusion matrix (cm) as an image using plt.imshow.
plt.colorbar(label='Number of samples'): This line adds a colorbar to the plot using plt.colorbar.
plt.xticks(np.arange(len(np.unique(y_test))), np.unique(y_test)): This line sets the tick labels and positions for the x-axis (predicted class) using plt.xticks.
np.arange(len(np.unique(y_test))) generates an array of indices corresponding to the unique values in y_test (which likely represent the predicted classes).
np.unique(y_test) gets the unique class labels from y_test. These labels are used as tick labels for the x-axis.
plt.yticks(np.arange(len(np.unique(preds))), np.unique(preds)): This line sets the tick labels and positions for the y-axis (true class) using plt.yticks. Similar to the x-axis, it uses np.unique(preds) (likely representing the true classes) to set the tick labels.
plt.text(0, 0, str(cm[0, 0]), ha='center', va='center', fontsize=12, color='white'): This line adds text to the top-left corner (cell (0, 0)) of the confusion matrix plot using plt.text.