2

I am able to build a model with bigrf() package, but is there a way to predict probabilities instead of classes? For class prediction I use

predictions <- predict(forest, test, testset$y)

forest is a model. I tried type = "prob" but does not do anything. Is there a way to do this?

I have big data, so I need to use this package in order to be able to process it.

UPD:

library(bigrf)
library(randomForest)

data("iris")
iris <- iris[iris$Species != "virginica",]
x <- iris[,1:4]
y <- iris$Species

vars <- c(1:4)
s = sample(1:nrow(x), 60)
registerDoParallel(cores=detectCores(all.tests=TRUE))
forest <- bigrfc(x[s, ], y[s], ntree=5L, varselect=vars)
predictions <- predict(forest, x[-s, ])

So, the question is how to get probabilities in predictions instead of classes from object class bigrfc?

MrFlick
  • 195,160
  • 17
  • 277
  • 295
Hobbit
  • 31
  • 3
  • 3
    It helps when you post a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). What is the class of `forest`? Did you look at the help page for that particular overloaded method? – MrFlick Jun 18 '15 at 04:41
  • Thanks for the comment, I updated the question. Sure, I checked predict method for bigrf class, but could not find any hint there on how to predict prob. – Hobbit Jun 18 '15 at 12:31
  • Don't edit your question to include the "answer". You should either accept the answer someone else posted by clicking the check mark next to the response, or if no other answers worked for you, post your own answer and accept it. – MrFlick Jun 18 '15 at 15:12

1 Answers1

1

According to this post, it should be possible to obtain the class probabilities with

predictions_probs <- predictions@testvotes/rowSums(predictions@testvotes)

I haven't tested it though. HTH.

RHertel
  • 23,412
  • 5
  • 38
  • 64
  • anyone know a consistent way to determine which columns correspond to which classes? – Mike Monteiro Aug 07 '15 at 14:15
  • attr(predictions@testvotes,"dimnames")$Class appears to give you a list of classes, but not positive that they're parallel-indexed to the columns in the prediction matrix – Mike Monteiro Aug 07 '15 at 15:04