Learn R Programming

spatialRF (version 1.1.5)

get_predictions: Extract fitted predictions from model

Description

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

Usage

get_predictions(model)

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.

Arguments

model

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

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().

See Also

rf(), rf_repeat(), rf_spatial(), get_residuals()

Other model_info: get_evaluation(), get_importance(), get_importance_local(), get_moran(), get_performance(), get_residuals(), get_response_curves(), get_spatial_predictors(), print.rf(), print_evaluation(), print_importance(), print_moran(), print_performance()

Examples

Run this code
data(plants_rf)

# Extract fitted predictions
predictions <- get_predictions(plants_rf)
head(predictions)

# Check length matches number of observations
length(predictions)

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

Run the code above in your browser using DataLab