Skip to contents

Extracts fitted (in-sample) predictions from models fitted with rf(), rf_repeat(), or rf_spatial().

Usage

get_predictions(model)

Arguments

model

Model object from rf(), rf_repeat(), or rf_spatial().

Value

Numeric vector of fitted predictions with length equal to the number of training observations. For rf_repeat() models, returns the median prediction across repetitions.

Details

This function returns fitted predictions for the training data used to build the model, not predictions for new data. For out-of-sample predictions on new data use stats::predict().

Examples

data(plants_rf)

# Extract fitted predictions
predictions <- get_predictions(plants_rf)
head(predictions)
#> [1] 4893.039 5554.766 1520.714 6482.056 9677.114 2902.869

# Check length matches number of observations
length(predictions)
#> [1] 227

# Compare with observed values to assess fit
# (observed values would be in original data)