Plot A Confusion Matrix with Color and Frequency in R -


i want plot confusion matrix, but, don't want use heatmap, because think give poor numerical resolution. instead, want plot frequency in middle of square. instance, output of this:

library(mlearning); data("glass", package = "mlbench") glass$type <- as.factor(paste("glass", glass$type))  summary(glasslvq <- mllvq(type ~ ., data = glass)); (glassconf <- confusion(predict(glasslvq, glass, type = "class"), glass$type))  plot(glassconf) # image default 

however, 1.) don't understand "01, 02, etc" means along each axis. how can rid of that? 2.) 'predicted' label of 'y' dimension, , 'actual' label 'x' dimension 3.) replace absolute counts frequency / probability.

alternatively, there package this?

in essence, want in r:

http://www.mathworks.com/help/releases/r2013b/nnet/gs/gettingstarted_nprtool_07.gif

or:

http://c431376.r76.cf2.rackcdn.com/8805/fnhum-05-00189-html/image_m/fnhum-05-00189-g009.jpg

the mlearning package seems quite inflexible plotting confusion matrices.

starting glassconf object, want this:

prior(glassconf) <- 100  # above rescales confusion matrix such columns sum 100. opar <- par(mar=c(5.1, 6.1, 2, 2)) x <- x.orig <- unclass(glassconf) x <- log(x + 0.5) * 2.33 x[x < 0] <- na x[x > 10] <- 10 diag(x) <- -diag(x) image(1:ncol(x), 1:ncol(x),       -(x[, nrow(x):1]), xlab='actual', ylab='',       col=colorramppalette(c(hsv(h = 0, s = 0.9, v = 0.9, alpha = 1),                               hsv(h = 0, s = 0, v = 0.9, alpha = 1),                               hsv(h = 2/6, s = 0.9, v = 0.9, alpha = 1)))(41),        xaxt='n', yaxt='n', zlim=c(-10, 10)) axis(1, at=1:ncol(x), labels=colnames(x), cex.axis=0.8) axis(2, at=ncol(x):1, labels=colnames(x), las=1, cex.axis=0.8) title(ylab='predicted', line=4.5) abline(h = 0:ncol(x) + 0.5, col = 'gray') abline(v = 0:ncol(x) + 0.5, col = 'gray') text(1:6, rep(6:1, each=6),       labels = sub('^0$', '', round(c(x.orig), 0))) box(lwd=2) par(opar) # reset par 

the above code uses bits , pieces of confusionimage function called plot.confusion.

confusion matrix


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -