Send output to:
Browser Blue - Charts White
Browser Black/White
CSV
Data X:
1575 129988 81 505 109 0 20 1134 130358 46 329 68 1 38 192 7215 18 72 1 0 0 2044 112976 87 588 146 0 49 3283 219904 126 1100 124 0 76 5877 402036 218 1618 267 1 104 1322 117604 50 442 83 1 37 1225 131822 50 333 48 0 57 1463 99729 38 406 87 0 42 2671 269088 87 858 129 1 67 1810 113066 69 568 146 2 50 1915 165392 62 595 113 0 66 1452 78240 90 534 60 0 38 2415 152673 84 818 240 4 48 1254 134368 47 359 50 4 42 1375 125769 68 419 81 3 47 1504 123467 50 364 85 0 71 1016 57396 49 290 64 5 0 2222 108458 79 683 127 0 50 634 22762 21 188 44 0 12 849 48633 50 291 37 0 16 2189 182081 83 640 94 0 77 1520 149502 61 542 127 0 32 1791 93773 46 532 159 1 38 1751 133428 79 549 41 1 50 1180 113933 23 428 153 0 33 1750 153851 140 561 86 0 49 1101 140711 75 266 55 0 59 2398 303863 106 785 78 0 55 1826 163810 38 754 84 0 42 1410 134521 41 411 71 0 47 1433 157640 39 482 111 2 51 1893 103274 90 593 82 4 45 2525 193500 105 760 254 0 73 2033 178768 43 668 66 1 51 1 0 1 0 0 0 0 1817 181412 55 855 58 0 46 1506 92342 47 464 131 3 44 1924 115762 42 453 261 9 33 1649 178277 50 607 56 0 71 1672 145067 58 540 90 2 61 1433 114146 50 551 57 0 28 866 86039 26 310 35 2 21 1683 125481 66 647 53 1 42 1024 95535 42 321 46 2 44 1029 129221 78 262 38 2 40 629 61554 26 180 45 1 15 1693 170811 83 587 114 0 46 1715 159121 75 544 104 1 43 2248 137317 52 809 151 4 57 658 48188 28 205 37 0 12 1234 95461 56 317 49 0 46 2157 249356 65 734 83 0 60 1725 191094 68 590 67 0 47 1504 161082 51 546 39 1 50 1454 111388 47 443 69 6 35 1620 172614 58 429 58 0 45 733 63205 18 205 68 0 25 894 109102 56 310 30 0 47 2355 137519 75 788 54 10 28 1514 125777 51 438 65 6 48 1636 88650 66 605 81 0 32 1123 95845 50 318 84 11 28 897 83419 29 288 45 3 31 855 101723 25 285 52 0 13 1229 94982 37 391 36 0 38 2012 145568 62 453 80 8 49 2393 113325 63 715 144 2 68 878 87133 33 219 48 0 36 340 31970 15 101 40 0 5 2480 194516 103 875 126 3 53 1071 98324 56 321 75 1 36 1091 80820 56 360 54 2 54 1425 89141 60 429 84 1 37 2227 118147 55 568 89 0 52 1082 56544 32 292 62 2 0 1790 118838 52 499 105 1 52 2072 118781 80 690 63 0 51 816 60138 23 253 76 0 16 1121 73422 66 366 92 0 33 834 70248 60 201 45 0 48 1766 225857 54 652 57 0 35 751 51185 24 221 44 0 24 1309 97181 32 438 132 0 37 732 45100 39 247 44 0 17 1327 115801 43 388 67 0 32 2246 186310 190 541 82 0 55 968 71960 86 233 71 0 39 1015 80105 48 333 44 5 31 1149 110416 43 440 72 0 26 1301 98707 34 452 54 4 37 1982 136234 67 584 86 1 66 1091 136781 52 366 59 0 35 1162 116132 54 433 74 0 24 759 49164 33 291 30 0 22 1980 189493 93 632 156 0 42 1608 169406 50 491 87 0 86 223 19349 12 67 15 0 13 1810 160902 88 617 104 1 21 1466 109510 53 597 54 0 32 553 43803 25 240 11 0 8 708 47062 19 219 37 0 38 1079 110845 44 349 80 0 45 957 92517 52 241 66 1 24 585 58660 36 136 27 0 23 596 27676 22 194 59 0 2 981 98550 33 222 113 0 52 585 43646 24 153 24 0 5 0 0 0 0 0 0 0 975 75566 28 281 58 0 43 751 57359 49 240 43 0 18 1071 104330 36 358 45 0 44 931 70369 47 302 55 0 45 783 65494 56 267 66 0 29 78 3616 5 14 5 0 0 0 0 0 0 0 0 0 874 143931 37 287 67 0 32 1327 117946 66 476 67 0 65 1831 137332 85 519 118 1 26 750 84336 33 243 51 0 24 778 43410 19 292 63 0 7 1442 139695 61 430 88 1 62 807 79015 34 217 35 0 30 1613 106116 47 466 58 8 54 685 57586 38 160 29 3 3 285 19764 12 75 19 1 10 1418 112195 43 442 51 2 46 954 103651 25 332 64 0 23 1283 113402 35 417 96 0 40 256 11796 9 79 22 0 1 81 7627 9 25 7 0 0 1215 121085 50 431 34 0 29 41 6836 3 11 5 0 0 1634 139563 46 564 43 5 46 42 5118 3 6 1 0 5 528 40248 16 183 34 1 8 0 0 0 0 0 0 0 890 95079 42 295 49 0 21 1203 80763 32 230 44 0 21 81 7131 4 27 0 1 0 61 4194 11 14 4 0 0 849 60378 20 240 40 1 15 1035 109173 44 251 52 0 47 964 83484 16 347 47 0 17
Names of X columns:
Pageviews timeRFC logins compviews viewsPR sharedcomp blogged
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