Predict method for the rforest function

# S3 method for rforest
predict(
  object,
  pred_data = NULL,
  pred_cmd = "",
  pred_names = "",
  OOB = NULL,
  dec = 3,
  envir = parent.frame(),
  ...
)

Arguments

object

Return value from rforest

pred_data

Provide the dataframe to generate predictions (e.g., diamonds). The dataset must contain all columns used in the estimation

pred_cmd

Generate predictions using a command. For example, `pclass = levels(pclass)` would produce predictions for the different levels of factor `pclass`. To add another variable, create a vector of prediction strings, (e.g., c('pclass = levels(pclass)', 'age = seq(0,100,20)')

pred_names

Names for the predictions to be stored. If one name is provided, only the first column of predictions is stored. If empty, the levels in the response variable of the rforest model will be used

OOB

Use Out-Of-Bag predictions (TRUE or FALSE). Relevant when evaluating predictions for the training sample. If missing, datasets will be compared to determine of OOB predictions should be used

dec

Number of decimals to show

envir

Environment to extract data from

...

further arguments passed to or from other methods

Details

See https://radiant-rstats.github.io/docs/model/rforest.html for an example in Radiant

See also

rforest to generate the result

summary.rforest to summarize results

Examples

result <- rforest(titanic, "survived", c("pclass", "sex"), lev = "Yes") predict(result, pred_cmd = "pclass = levels(pclass)")
#> Random Forest #> Data : titanic #> Response variable : survived #> Level(s) : Yes in survived #> Explanatory variables: pclass, sex #> Prediction command : pclass = levels(pclass) #> Additional arguments : OOB = NULL #> #> sex pclass Yes No #> male 1st 0.833 0.167 #> male 2nd 0.816 0.184 #> male 3rd 0.505 0.495
result <- rforest(diamonds, "price", "carat:color", type = "regression") predict(result, pred_cmd = "carat = 1:3")
#> Random Forest #> Data : diamonds #> Response variable : price #> Explanatory variables: carat, clarity, cut, color #> Prediction command : carat = 1:3 #> Additional arguments : OOB = NULL #> #> clarity cut color carat Prediction #> SI1 Ideal G 1 3014.741 #> SI1 Ideal G 2 8309.019 #> SI1 Ideal G 3 9859.129
predict(result, pred_data = diamonds) %>% head()
#> Using OOB predictions after comparing the training and prediction data
#> Using OOB predictions
#> Random Forest #> Data : diamonds #> Response variable : price #> Explanatory variables: carat, clarity, cut, color #> Prediction dataset : diamonds #> Additional arguments : OOB = NULL #> #> carat clarity cut color Prediction #> 0.320 VS1 Ideal H 602.805 #> 0.340 SI1 Very Good G 576.379 #> 0.300 VS2 Very Good G 545.945 #> 0.350 VVS2 Ideal H 748.498 #> 0.400 VS2 Premium F 1009.561 #> 0.600 VVS1 Ideal E 2865.482