Skip to content

Commit

Permalink
cforest updates
Browse files Browse the repository at this point in the history
  • Loading branch information
topepo committed May 26, 2018
1 parent 2b795b3 commit d7cfe74
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions models/files/cforest.R
Expand Up @@ -44,7 +44,7 @@ modelInfo <- list(label = "Conditional Inference Random Forest",
## party builds the levels into the model object, so I'm
## going to assume that all the levels will be passed to
## the output
out <- predict(modelFit, newdata, OOB = TRUE)
out <- party:::predict.RandomForest(modelFit, newdata = newdata, OOB = TRUE)
if(is.matrix(out)) out <- out[,1]
if(!is.null(modelFit@responses@levels$.outcome)) out <- as.character(out)

Expand All @@ -53,19 +53,19 @@ modelInfo <- list(label = "Conditional Inference Random Forest",
prob = function(modelFit, newdata = NULL, submodels = NULL) {
if(!is.null(newdata) && !is.data.frame(newdata)) newdata <- as.data.frame(newdata)
obsLevels <- levels(modelFit@data@get("response")[,1])
rawProbs <- party::treeresponse(modelFit, newdata, OOB = TRUE)
rawProbs <- party::treeresponse(modelFit, newdata = newdata, OOB = TRUE)
probMatrix <- matrix(unlist(rawProbs), ncol = length(obsLevels), byrow = TRUE)
out <- data.frame(probMatrix)
colnames(out) <- obsLevels
rownames(out) <- NULL
out
},
predictors = function(x, ...) {
vi <- varimp(x, ...)
vi <- party::varimp(x, ...)
names(vi)[vi != 0]
},
varImp = function(object, ...) {
variableImp <- varimp(object, ...)
variableImp <- party::varimp(object, ...)
out <- data.frame(Overall = variableImp)
out
},
Expand All @@ -74,6 +74,6 @@ modelInfo <- list(label = "Conditional Inference Random Forest",
sort = function(x) x[order(x[,1]),],
oob = function(x) {
obs <- x@data@get("response")[,1]
pred <- predict(x, OOB = TRUE)
pred <- party:::predict.RandomForest(x, OOB = TRUE)
postResample(pred, obs)
})
Binary file modified pkg/caret/inst/models/models.RData
Binary file not shown.

0 comments on commit d7cfe74

Please sign in to comment.