[Zooimage-commits] r212 - pkg/zooimage/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jun 20 12:25:34 CEST 2012


Author: kevin
Date: 2012-06-20 12:25:33 +0200 (Wed, 20 Jun 2012)
New Revision: 212

Modified:
   pkg/zooimage/R/ZIConf.R
Log:
add confusionHclust function

Modified: pkg/zooimage/R/ZIConf.R
===================================================================
--- pkg/zooimage/R/ZIConf.R	2012-06-20 09:42:08 UTC (rev 211)
+++ pkg/zooimage/R/ZIConf.R	2012-06-20 10:25:33 UTC (rev 212)
@@ -171,6 +171,34 @@
 		cexCol = 0.2 + 1 / log10(nY), tracecol = "Black", linecol = FALSE)
 }
 
+# New graphical representation of the confusion based on the hclust strucute
+confusionHclust <- function (ZIClass, ZIConf = NULL, method = "ward")
+{
+    # Create confusion matrix
+    if(is.null(ZIConf)){
+        Confu <- ZIConf(ZIClass)
+    } else {
+	   Confu <- ZIConf
+    }
+    # Transform it in symetric confusion matrix
+    ConfuSim <- Confu + t(Confu)
+    ConfuSim <- max(ConfuSim) - ConfuSim
+    # Create the structure of a "dist" object
+    confuDist <- structure(confuSim[lower.tri(confuSim)],
+        Size = nrow(confu),
+        Diag = FALSE,
+        Upper = FALSE,
+        method = "confusion",
+        call = "",
+        class = "dist"
+    )
+    # method :"ward", "single", "complete", "average", "mcquitty", "median" or "centroid"
+    HC <- hclust(confuDist, method = "ward")
+    plot(HC, labels = rownames(confu))
+    return(invisible(HC))
+}
+
+
 # Confusion bar with recall and precision in green bar and not outside as before
 # function modified for publication hclust 
 confusionBar <- function (ZIConf, col = c("PeachPuff2", "green3", "lemonChiffon2"),



More information about the Zooimage-commits mailing list