|
AUCRF 包:
AUC.randomForest <- function(rf, clase = 1) {
r <- rank(rf$votes[, as.character(clase)])
rd <- mean(r[rf$y == clase])
nd <- sum(rf$y == clase)
nnd <- length(rf$y) - nd
return((rd - nd/2 - 0.5)/nnd)
}
while (k >= k0) {
fitRF <- randomForest(formula, data = data[, c(yname,
vars[1:k])], ...)
getAUC <- AUC.randomForest(fitRF)
randomForest 包:
查看
randomForest:::randomForest.default
randomForest=function(......
out.votes <- t(matrix(rfout$counttr, nclass, nsample))[1:n, ]
if (norm.votes)
out.votes <- t(apply(out.votes, 1, function(x) x/sum(x)))
class(out.votes) <- c(class(out.votes), "votes")
out <- list(call = cl, type = if (addclass) "unsupervised" else "classification",
predicted = if (addclass) NULL else out.class, err.rate = if (addclass) NULL else t(matrix(rfout$errtr,
nclass + 1, ntree, dimnames = list(c("OOB", levels(y)),
NULL))), confusion = if (addclass) NULL else con,
votes = out.votes, oob.times = oob.times, classes = levels(y), ....)
class(out)<-"randomForest"
methods(print.randomForest)
randomForest:::print.randomForest
数据的结构一环扣一环的,慢慢看吧。自虐了一回,希望有帮助
|