title: Using randomForest package in R, how to get probabilities from classification model?
body: <p>TL;DR :</p>
  
  <p><strong><em>Is there something I can flag in the original</em></strong> <code>randomForest</code> <strong><em>call to avoid having to re-run the</em></strong> <code>predict</code> <strong><em>function to get predicted categorical probabilities, instead of just the likely category?</em></strong></p>
  
  <p>Details:</p>
  
  <p>I am using the <a href="http://cran.r-project.org/web/packages/randomForest/randomForest.pdf">randomForest</a> package.</p>
  
  <p>I have a model something like:</p>
  
  <pre><code>model &lt;- randomForest(x=out.data[train.rows, feature.cols],
                        y=out.data[train.rows, response.col],
                        xtest=out.data[test.rows, feature.cols],
                        ytest=out.data[test.rows, response.col],
                        importance= TRUE)
  </code></pre>
  
  <p>where <code>out.data</code> is a data frame, with <code>feature.cols</code> a mixture of numeric and categorical features, while <code>response.col</code> is a <code>TRUE</code> / <code>FALSE</code> binary variable, that I forced into <code>factor</code> so that <code>randomForest</code> model will properly treat it as categorical.</p>
  
  <p>All runs well, and the variable <code>model</code> is returned to me properly.  However, I cannot seem to find a flag or parameter to pass to the <code>randomForest</code> function so that <code>model</code> is returned to me with the <strong><em>probabilities</em></strong> of <code>TRUE</code> or <code>FALSE</code>.  Instead, I get simply predicted values.  That is, if I look at <code>model$predicted</code>, I'll see something like:</p>
  
  <pre><code>FALSE
  FALSE
  TRUE
  TRUE
  FALSE
  .
  .
  .
  </code></pre>
  
  <p>Instead, I want to see something like:</p>
  
  <pre><code>   FALSE  TRUE
  1  0.84   0.16
  2  0.66   0.34
  3  0.11   0.89
  4  0.17   0.83
  5  0.92   0.08
  .   .      .
  .   .      .
  .   .      .
  </code></pre>
  
  <p>I can get the above, but in order to do so, I need to do something like:</p>
  
  <pre><code>tmp &lt;- predict(model, out.data[test.rows, feature.cols], "prob")
  </code></pre>
  
  <p>[<code>test.rows</code> captures the row numbers for those that were used during the model testing.  The details are not shown here, but are simple since the test row IDs are output into <code>model</code>.]</p>
  
  <p>Then everything works fine.  The <strong><em>problem</em></strong> is that the model is big and takes a very long time to run, and even the prediction itself takes a while.  Since the prediction <strong><em>should</em></strong> be entirely unnecessary (I am simply looking to calculate the ROC curve on the test data set, the data set that should have already been calculated), I was hoping to skip this step.  <strong><em>Is there something I can flag in the original</em></strong> <code>randomForest</code> <strong><em>call to avoid having to re-run the</em></strong> <code>predict</code> <strong><em>function?</em></strong></p>