### R代码来自vignette源代码的MLInterfaces。Rnw ' ################################################### ### 代码块1号:MLInterfaces。Rnw: 108 - 111 ################################################### 库(MLInterfaces)图书馆(golubEsets)图书馆(genefilter ) ################################################### ### 代码块2号:redu ################################################### 数据(Golub_Merge) smallG < - Golub_Merge 200:259, smallG ################################################### ### 代码块3号:doknnB ################################################### # 所有krun < knnB (smallG。”AML", trainInd=1:40) krun = MLearn(ALL.AML~。、smallG knnI (k = 1), 1) krun ################################################### ### 代码块数量4:lkco ################################################### confuMat (krun ) ################################################### ### 代码块5号:lkco2 ################################################### set.seed (1234) # nns < - nnetB (smallG[1:10,],”所有。AML”,trainInd=1:40, size=2, decay=。01, maxit=250) nns <- MLearn(ALL.AML~。, smallG[1:10,], nnetI, trainInd=1:40, size=2, decay=。01,麦克斯特= 250)nns confuMat(海军新闻 ) ################################################### ### 代码块6号:MLInterfaces。Rnw: 179 - 180 (eval = FALSE ) ################################################### ## (RObject(海军新闻摘要 )) ################################################### ### 代码块7号:MLInterfaces。Rnw: 184 - 185 (eval = FALSE ) ################################################### ## ags < - agnesB (smallG k = 4,身高= 0,站= FALSE ) ################################################### ### 代码块8号:MLInterfaces。Rnw: 186 - 187 (eval = FALSE ) ################################################### ## 情节(RObject (ags) which.plot = 2 ) ################################################### ### 代码块9号:lkci ################################################### getClass (learnerSchema) getClass(“xvalSpec ") ################################################### ### 代码块10号: lkcc ################################################### getClass("classifierOutput") ################################################### ### code chunk number 11: lkcl (eval = FALSE) ################################################### ## getClass("clustOutput") ################################################### ### code chunk number 12: dox ################################################### library(golubEsets) data(Golub_Merge) smallG <- Golub_Merge[200:250,] lk1 <- MLearn(ALL.AML~., smallG, knnI(k=1,l=0), xvalSpec("LOO")) confuMat(lk1) ################################################### ### code chunk number 13: doxr ################################################### ranpart = function(K, data) { N = nrow(data) cu = as.numeric(cut(1:N, K)) sample(cu, size=N, replace=FALSE) } ranPartition = function(K) function(data, clab, iternum) { p = ranpart(K, data) which(p != iternum) # to retain training fraction } lkran <- MLearn(ALL.AML~., smallG, knnI(k=1,l=0), xvalSpec("LOG", 8, partitionFunc=ranPartition(8))) confuMat(lkran) ################################################### ### code chunk number 14: dox2 ################################################### lk3 <- MLearn(ALL.AML~., smallG, knnI(k=1,l=0), xvalSpec("LOG", 8, partitionFunc=balKfold.xvspec(8))) confuMat(lk3) ################################################### ### code chunk number 15: dofs ################################################### data(iris) iris2 = iris[ iris$Species %in% levels(iris$Species)[1:2], ] iris2$Species = factor(iris2$Species) # drop unused levels x1 = MLearn(Species~., iris2, ldaI, xvalSpec("LOG", 3, balKfold.xvspec(3), fs.absT(3))) fsHistory(x1) ################################################### ### code chunk number 16: getpp ################################################### predProb <- round(testScores(nns),3) ################################################### ### code chunk number 17: gettrue ################################################### truth <- as.character(smallG$ALL.AML[-c(1:40)]) simpPred <- as.character(testPredictions(nns)) ################################################### ### code chunk number 18: mkclo ################################################### douClo <- function(pprob) function(lo,hi) pprob>lo & pprob