Send output to:
Browser Blue - Charts White
Browser Black/White
CSV
Data X:
1565 129404 20 18 63 18158 1134 130358 38 17 50 30461 192 7215 0 0 0 1423 2033 112861 49 22 51 25629 3283 219904 76 30 112 48758 5877 402036 104 31 118 129230 1322 117604 37 19 59 27376 1225 131822 57 25 90 26706 1463 99729 42 30 50 26505 2568 256310 62 26 79 49801 1810 113066 50 20 49 46580 1915 165392 66 30 91 48352 1452 78240 38 15 32 13899 2415 152673 48 22 82 39342 1254 134368 42 17 58 27465 1374 125769 47 19 65 55211 1504 123467 71 28 111 74098 999 56232 0 12 36 13497 2222 108458 50 28 89 38338 634 22762 12 13 28 52505 849 48633 16 14 35 10663 2189 182081 77 27 78 74484 1469 140857 29 25 67 28895 1791 93773 38 30 61 32827 1743 133398 50 21 58 36188 1180 113933 33 17 49 28173 1749 153851 49 22 77 54926 1101 140711 59 28 71 38900 2391 303844 55 26 85 88530 1826 163810 42 17 56 35482 1301 123344 40 23 71 26730 1433 157640 51 20 58 29806 1893 103274 45 16 34 41799 2525 193500 73 20 59 54289 2033 178768 51 21 77 36805 1 0 0 0 0 0 1817 181412 46 27 75 33146 1506 92342 44 14 39 23333 1820 100023 31 29 83 47686 1649 178277 71 31 123 77783 1672 145067 61 19 67 36042 1433 114146 28 30 105 34541 864 86039 21 23 76 75620 1683 125481 42 21 57 60610 1024 95535 44 22 82 55041 1029 129221 40 21 64 32087 629 61554 15 32 57 16356 1679 168048 46 20 80 40161 1715 159121 43 26 94 55459 2093 129362 47 25 72 36679 658 48188 12 22 39 22346 1234 95461 46 19 60 27377 2059 229864 56 24 84 50273 1725 191094 47 26 69 32104 1504 161082 50 27 102 27016 1454 111388 35 10 28 19715 1620 172614 45 26 65 33629 733 63205 25 23 67 27084 894 109102 47 21 80 32352 2343 137303 28 34 79 51845 1503 125304 48 29 107 26591 1627 88620 32 19 60 29677 1119 95808 28 19 53 54237 897 83419 31 23 59 20284 855 101723 13 22 80 22741 1229 94982 38 29 89 34178 1991 143566 48 31 115 69551 2393 113325 68 21 59 29653 820 81518 32 21 66 38071 340 31970 5 21 42 4157 2443 192268 53 15 35 28321 1030 91261 33 9 3 40195 1091 80820 54 23 72 48158 1414 85829 37 18 38 13310 2192 116322 52 31 107 78474 1082 56544 0 25 73 6386 1764 116173 52 24 80 31588 2072 118781 51 22 69 61254 816 60138 16 21 46 21152 1121 73422 33 26 52 41272 810 67751 48 22 58 34165 1699 214002 33 26 85 37054 751 51185 24 20 13 12368 1309 97181 37 25 61 23168 732 45100 17 19 49 16380 1327 115801 32 22 47 41242 2246 186310 55 25 93 48450 968 71960 39 22 65 20790 1015 80105 31 21 64 34585 1100 103613 26 20 64 35672 1300 98707 37 23 57 52168 1982 136234 66 22 61 53933 1091 136781 35 21 71 34474 1107 105863 24 12 43 43753 666 42228 22 9 18 36456 1903 179997 37 32 103 51183 1608 169406 86 24 76 52742 223 19349 13 1 0 3895 1807 160819 21 24 83 37076 1466 109510 32 25 73 24079 552 43803 8 4 4 2325 708 47062 38 15 41 29354 1079 110845 45 21 57 30341 957 92517 24 23 52 18992 585 58660 23 12 24 15292 596 27676 2 16 17 5842 980 98550 52 24 89 28918 585 43646 5 9 20 3738 0 0 0 0 0 0 975 75566 43 25 51 95352 750 57359 18 17 63 37478 1071 104330 44 18 48 26839 931 70369 45 21 70 26783 783 65494 29 17 32 33392 78 3616 0 0 0 0 0 0 0 0 0 0 874 143931 32 20 72 25446 1327 117946 65 26 56 59847 1831 137332 26 27 66 28162 750 84336 24 20 77 33298 778 43410 7 1 3 2781 1373 136250 62 24 73 37121 807 79015 30 14 37 22698 1562 101354 49 27 57 27615 685 57586 3 12 32 32689 285 19764 10 2 4 5752 1336 105757 42 16 55 23164 954 103651 23 23 84 20304 1283 113402 40 28 90 34409 256 11796 1 2 1 0 81 7627 0 0 0 0 1214 121085 29 17 38 92538 41 6836 0 1 0 0 1634 139563 46 17 36 46037 42 5118 5 0 0 0 528 40248 8 4 7 5444 0 0 0 0 0 0 890 95079 21 25 75 23924 1203 80763 21 26 52 52230 81 7131 0 0 0 0 61 4194 0 0 0 0 849 60378 15 15 45 8019 1035 109173 47 20 66 34542 964 83484 17 19 48 21157
Names of X columns:
pageviews time blogs peerreviews peerreviews+ compcharachters
Endogenous Variable (Column Number)
Categorization
none
none
quantiles
hclust
equal
Number of categories (only if categorization<>none)
Cross-Validation? (only if categorization<>none)
no
no
yes
Chart options
R Code
library(party) library(Hmisc) par1 <- as.numeric(par1) par3 <- as.numeric(par3) x <- data.frame(t(y)) is.data.frame(x) x <- x[!is.na(x[,par1]),] k <- length(x[1,]) n <- length(x[,1]) colnames(x)[par1] x[,par1] if (par2 == 'kmeans') { cl <- kmeans(x[,par1], par3) print(cl) clm <- matrix(cbind(cl$centers,1:par3),ncol=2) clm <- clm[sort.list(clm[,1]),] for (i in 1:par3) { cl$cluster[cl$cluster==clm[i,2]] <- paste('C',i,sep='') } cl$cluster <- as.factor(cl$cluster) print(cl$cluster) x[,par1] <- cl$cluster } if (par2 == 'quantiles') { x[,par1] <- cut2(x[,par1],g=par3) } if (par2 == 'hclust') { hc <- hclust(dist(x[,par1])^2, 'cen') print(hc) memb <- cutree(hc, k = par3) dum <- c(mean(x[memb==1,par1])) for (i in 2:par3) { dum <- c(dum, mean(x[memb==i,par1])) } hcm <- matrix(cbind(dum,1:par3),ncol=2) hcm <- hcm[sort.list(hcm[,1]),] for (i in 1:par3) { memb[memb==hcm[i,2]] <- paste('C',i,sep='') } memb <- as.factor(memb) print(memb) x[,par1] <- memb } if (par2=='equal') { ed <- cut(as.numeric(x[,par1]),par3,labels=paste('C',1:par3,sep='')) x[,par1] <- as.factor(ed) } table(x[,par1]) colnames(x) colnames(x)[par1] x[,par1] if (par2 == 'none') { m <- ctree(as.formula(paste(colnames(x)[par1],' ~ .',sep='')),data = x) } load(file='createtable') if (par2 != 'none') { m <- ctree(as.formula(paste('as.factor(',colnames(x)[par1],') ~ .',sep='')),data = x) if (par4=='yes') { a<-table.start() a<-table.row.start(a) a<-table.element(a,'10-Fold Cross Validation',3+2*par3,TRUE) a<-table.row.end(a) a<-table.row.start(a) a<-table.element(a,'',1,TRUE) a<-table.element(a,'Prediction (training)',par3+1,TRUE) a<-table.element(a,'Prediction (testing)',par3+1,TRUE) a<-table.row.end(a) a<-table.row.start(a) a<-table.element(a,'Actual',1,TRUE) for (jjj in 1:par3) a<-table.element(a,paste('C',jjj,sep=''),1,TRUE) a<-table.element(a,'CV',1,TRUE) for (jjj in 1:par3) a<-table.element(a,paste('C',jjj,sep=''),1,TRUE) a<-table.element(a,'CV',1,TRUE) a<-table.row.end(a) for (i in 1:10) { ind <- sample(2, nrow(x), replace=T, prob=c(0.9,0.1)) m.ct <- ctree(as.formula(paste('as.factor(',colnames(x)[par1],') ~ .',sep='')),data =x[ind==1,]) if (i==1) { m.ct.i.pred <- predict(m.ct, newdata=x[ind==1,]) m.ct.i.actu <- x[ind==1,par1] m.ct.x.pred <- predict(m.ct, newdata=x[ind==2,]) m.ct.x.actu <- x[ind==2,par1] } else { m.ct.i.pred <- c(m.ct.i.pred,predict(m.ct, newdata=x[ind==1,])) m.ct.i.actu <- c(m.ct.i.actu,x[ind==1,par1]) m.ct.x.pred <- c(m.ct.x.pred,predict(m.ct, newdata=x[ind==2,])) m.ct.x.actu <- c(m.ct.x.actu,x[ind==2,par1]) } } print(m.ct.i.tab <- table(m.ct.i.actu,m.ct.i.pred)) numer <- 0 for (i in 1:par3) { print(m.ct.i.tab[i,i] / sum(m.ct.i.tab[i,])) numer <- numer + m.ct.i.tab[i,i] } print(m.ct.i.cp <- numer / sum(m.ct.i.tab)) print(m.ct.x.tab <- table(m.ct.x.actu,m.ct.x.pred)) numer <- 0 for (i in 1:par3) { print(m.ct.x.tab[i,i] / sum(m.ct.x.tab[i,])) numer <- numer + m.ct.x.tab[i,i] } print(m.ct.x.cp <- numer / sum(m.ct.x.tab)) for (i in 1:par3) { a<-table.row.start(a) a<-table.element(a,paste('C',i,sep=''),1,TRUE) for (jjj in 1:par3) a<-table.element(a,m.ct.i.tab[i,jjj]) a<-table.element(a,round(m.ct.i.tab[i,i]/sum(m.ct.i.tab[i,]),4)) for (jjj in 1:par3) a<-table.element(a,m.ct.x.tab[i,jjj]) a<-table.element(a,round(m.ct.x.tab[i,i]/sum(m.ct.x.tab[i,]),4)) a<-table.row.end(a) } a<-table.row.start(a) a<-table.element(a,'Overall',1,TRUE) for (jjj in 1:par3) a<-table.element(a,'-') a<-table.element(a,round(m.ct.i.cp,4)) for (jjj in 1:par3) a<-table.element(a,'-') a<-table.element(a,round(m.ct.x.cp,4)) a<-table.row.end(a) a<-table.end(a) table.save(a,file='mytable3.tab') } } m bitmap(file='test1.png') plot(m) dev.off() bitmap(file='test1a.png') plot(x[,par1] ~ as.factor(where(m)),main='Response by Terminal Node',xlab='Terminal Node',ylab='Response') dev.off() if (par2 == 'none') { forec <- predict(m) result <- as.data.frame(cbind(x[,par1],forec,x[,par1]-forec)) colnames(result) <- c('Actuals','Forecasts','Residuals') print(result) } if (par2 != 'none') { print(cbind(as.factor(x[,par1]),predict(m))) myt <- table(as.factor(x[,par1]),predict(m)) print(myt) } bitmap(file='test2.png') if(par2=='none') { op <- par(mfrow=c(2,2)) plot(density(result$Actuals),main='Kernel Density Plot of Actuals') plot(density(result$Residuals),main='Kernel Density Plot of Residuals') plot(result$Forecasts,result$Actuals,main='Actuals versus Predictions',xlab='Predictions',ylab='Actuals') plot(density(result$Forecasts),main='Kernel Density Plot of Predictions') par(op) } if(par2!='none') { plot(myt,main='Confusion Matrix',xlab='Actual',ylab='Predicted') } dev.off() if (par2 == 'none') { detcoef <- cor(result$Forecasts,result$Actuals) a<-table.start() a<-table.row.start(a) a<-table.element(a,'Goodness of Fit',2,TRUE) a<-table.row.end(a) a<-table.row.start(a) a<-table.element(a,'Correlation',1,TRUE) a<-table.element(a,round(detcoef,4)) a<-table.row.end(a) a<-table.row.start(a) a<-table.element(a,'R-squared',1,TRUE) a<-table.element(a,round(detcoef*detcoef,4)) a<-table.row.end(a) a<-table.row.start(a) a<-table.element(a,'RMSE',1,TRUE) a<-table.element(a,round(sqrt(mean((result$Residuals)^2)),4)) a<-table.row.end(a) a<-table.end(a) table.save(a,file='mytable1.tab') a<-table.start() a<-table.row.start(a) a<-table.element(a,'Actuals, Predictions, and Residuals',4,TRUE) a<-table.row.end(a) a<-table.row.start(a) a<-table.element(a,'#',header=TRUE) a<-table.element(a,'Actuals',header=TRUE) a<-table.element(a,'Forecasts',header=TRUE) a<-table.element(a,'Residuals',header=TRUE) a<-table.row.end(a) for (i in 1:length(result$Actuals)) { a<-table.row.start(a) a<-table.element(a,i,header=TRUE) a<-table.element(a,result$Actuals[i]) a<-table.element(a,result$Forecasts[i]) a<-table.element(a,result$Residuals[i]) a<-table.row.end(a) } a<-table.end(a) table.save(a,file='mytable.tab') } if (par2 != 'none') { a<-table.start() a<-table.row.start(a) a<-table.element(a,'Confusion Matrix (predicted in columns / actuals in rows)',par3+1,TRUE) a<-table.row.end(a) a<-table.row.start(a) a<-table.element(a,'',1,TRUE) for (i in 1:par3) { a<-table.element(a,paste('C',i,sep=''),1,TRUE) } a<-table.row.end(a) for (i in 1:par3) { a<-table.row.start(a) a<-table.element(a,paste('C',i,sep=''),1,TRUE) for (j in 1:par3) { a<-table.element(a,myt[i,j]) } a<-table.row.end(a) } a<-table.end(a) table.save(a,file='mytable2.tab') }
Compute
Summary of computational transaction
Raw Input
view raw input (R code)
Raw Output
view raw output of R engine
Computing time
2 seconds
R Server
Big Analytics Cloud Computing Center
Click here to blog (archive) this computation