From: Aaron A. <aa...@us...> - 2008-08-15 21:50:15
|
Update of /cvsroot/jboost/jboost/scripts In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv28672 Modified Files: README atreeplot.R Log Message: Small bug fixes and more documentation Index: README =================================================================== RCS file: /cvsroot/jboost/jboost/scripts/README,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** README 31 Jul 2008 22:15:33 -0000 1.1 --- README 15 Aug 2008 21:50:09 -0000 1.2 *************** *** 1,19 **** ! How to use scripts ----------------- Requirements: * R (version 2.6 or higher) ! * igraph (R package, can be obtained via install.packages or CRAN) ! * jboost (R package, can be obtained via install.packages or CRAN) - The best way to use the scripts is to install the jboost package. - This can be done by using the 'install.packages()' from R or by - downloading the JBoost package from CRAN and installing via 'R CMD - INSTALL jboost'. ! How to make the package: -------------------------- --- 1,24 ---- ! How to install scripts ----------------- Requirements: + * Python (tested with version 2.5.2, though lower version may work) * R (version 2.6 or higher) ! * igraph (R package, can be obtained via install.packages() or CRAN) + How to use the visualization scripts + -------------------------- + + source("atreeplot.R") + plot.atree(treefile="stem.output.tree", specfile="stem.spec") + + source("marginplot.R") + plot.margin(infofile="stem.train.boosting.info", specfile="stem.spec", iteration=c(10,50,100)) ! ! How to make the package -------------------------- Index: atreeplot.R =================================================================== RCS file: /cvsroot/jboost/jboost/scripts/atreeplot.R,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** atreeplot.R 31 Jul 2008 22:16:52 -0000 1.2 --- atreeplot.R 15 Aug 2008 21:50:11 -0000 1.3 *************** *** 37,41 **** ! plot.atree <- function(treefile, specfile, flip.labels=F, depth=-1, width=-1, height=-1) { labels = parse.labels(specfile) num.labels = length(labels); --- 37,41 ---- ! plot.atree <- function(treefile, specfile, flip.labels=F, depth=-1, plot.width=-1, plot.height=-1) { labels = parse.labels(specfile) num.labels = length(labels); *************** *** 79,83 **** label = x[4] predType = x[4]; ! #show(c(type, iteration, index, label)) x <- perl.re(predType, ".*MultiPrediction.*") y <- perl.re(predType, ".*BinaryPrediction.*=(.*)") --- 79,83 ---- label = x[4] predType = x[4]; ! show(c(type, iteration, index, label)) x <- perl.re(predType, ".*MultiPrediction.*") y <- perl.re(predType, ".*BinaryPrediction.*=(.*)") *************** *** 102,105 **** --- 102,106 ---- } else if (y[1]=="TRUE") { label = y[2] + show(sprintf("label is %0.5f", label)) if(flip.labels) { label = as.numeric(label) *************** *** 107,110 **** --- 108,114 ---- label = as.character(label) } + } else { + error(paste("Do not recognize prediction type:", label)) + return } } *************** *** 154,163 **** ans <- substr(index,nchar(index), nchar(index)) if (ans=="0") { - E(g)$color[length(E(g))] <- "red" - E(g)$label[length(E(g))] <- "False" - } else if (ans=="1") { E(g)$color[length(E(g))] <- "green" ! E(g)$label[length(E(g))] <- "True" ! } else { error(paste("The splitter has an invalid return value!\n 1 or 0 expected, recieved", ans)) } --- 158,167 ---- ans <- substr(index,nchar(index), nchar(index)) if (ans=="0") { E(g)$color[length(E(g))] <- "green" ! E(g)$label[length(E(g))] <- " Yes" ! } else if (ans=="1") { ! E(g)$color[length(E(g))] <- "red" ! E(g)$label[length(E(g))] <- "No " ! } else { error(paste("The splitter has an invalid return value!\n 1 or 0 expected, recieved", ans)) } *************** *** 169,176 **** } ! w <- warnings() ! if (length(w)>0) { ! show(w) ! } i <- i + 1 } --- 173,180 ---- } ! #w <- warnings() ! #if (length(w)>0) { ! # show(w) ! #} i <- i + 1 } *************** *** 180,186 **** coords[,2] <- max(coords[,2])-coords[,2] fname <- sprintf("%s.eps", treefile) show(sprintf("Writing file to '%s'", fname)) ! postscript(file=sprintf("%s.eps", treefile), fonts=c("serif", "Palatino"), paper="special", width=70, height=40, horizontal=TRUE) plot(1, type="n", axes=FALSE, xlab=NA, ylab=NA, xlim=c(-1,1), ylim=c(-1,1)) sw <- strwidth(paste("", V(g)$label, "")) --- 184,198 ---- coords[,2] <- max(coords[,2])-coords[,2] + if(plot.width<0) { + plot.width <- 8 + } + if(plot.height<0) { + plot.height <- 9 + } + fname <- sprintf("%s.eps", treefile) show(sprintf("Writing file to '%s'", fname)) ! postscript(file=sprintf("%s.eps", treefile), fonts=c("serif", "Palatino"), ! paper="special", width=plot.width, height=plot.height, horizontal=TRUE) plot(1, type="n", axes=FALSE, xlab=NA, ylab=NA, xlim=c(-1,1), ylim=c(-1,1)) sw <- strwidth(paste("", V(g)$label, "")) |