[R] How do I extract Random Forest Terms and Probabilities?

arun smartpink111 at yahoo.com
Wed Nov 27 00:56:52 CET 2013

For the first part, you could do:

fmi2 <- fmi 
attributes(fmi2$terms) <- NULL
#[1] "Species ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width"


On Tuesday, November 26, 2013 3:55 PM, "Lopez, Dan" <lopez235 at llnl.gov> wrote:
Hi R Experts,

I need your help with two question regarding randomForest.

1.       When I run a Random Forest model how do I extract the formula I used so that I can store it in a character vector in a dataframe?
For example the dataframe might look like this if I am running models using the IRIS dataset

#001,RF,Species ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width

#I know one place where the information is in fmi$terms but not sure how to extract just the formula info. Or perhaps there is somewhere else in fmi that I could get this?

2.       How do I get the probabilities (probability-like values) from the model that was run? I know for the test set I can use predict. And I know to extract the classifications from the model I use fmi$predicted. But where are the probabilities?

Workforce Analyst
HRIM - Workforce Analytics & Metrics

    [[alternative HTML version deleted]]

R-help at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list