Solved – the best way of graphical or visual representation of confusion matrix

classificationconfusion matrixdata visualizationggplot2

I have classified the 15 classes dataset using machine learning algorithms. I don't want to put confusion matrix table since it is 15×15 matrix, instead, I want to represent it in a graphical way, which is more pleasant to visualize. Would you kindly recommend any technique? It would be better if it is using ggplot. Thank you so much. Waiting for your reply.

Best Answer

library('reshape2')
library('ggplot2')
mydata <- mtcars[, c(1,3,4,5,6,7)]
cormat <- round(cor(mydata),2)
melted_cormat <- melt(cormat)
ggplot(data = melted_cormat, aes(x=Var1, y=Var2, fill=value)) + geom_tile()

The above code calculates correlation between different features of the cars data. The correlation matrix is similar to confusion matrix both of them are square matrices.

Below is the visualisation of the correlation matrix.

enter image description here

If you have any doubts please comment below.

Related Question