| rf_compare | R Documentation |
Uses rf_evaluate() to compare the performance of several models on independent spatial folds via spatial cross-validation.
rf_compare(
models = NULL,
xy = NULL,
repetitions = 30,
training.fraction = 0.75,
metrics = c("r.squared", "pseudo.r.squared", "rmse", "nrmse", "auc"),
distance.step = NULL,
distance.step.x = NULL,
distance.step.y = NULL,
fill.color = viridis::viridis(100, option = "F", direction = -1, alpha = 0.8),
line.color = "gray30",
seed = 1,
verbose = TRUE,
n.cores = parallel::detectCores() - 1,
cluster = NULL
)
models |
Named list with models resulting from |
xy |
Data frame or matrix with two columns containing coordinates and named "x" and "y". Default: |
repetitions |
Integer, number of spatial folds to use during cross-validation. Must be lower than the total number of rows available in the model's data. Default: |
training.fraction |
Proportion between 0.5 and 0.9 indicating the proportion of records to be used as training set during spatial cross-validation. Default: |
metrics |
Character vector, names of the performance metrics selected. The possible values are: "r.squared" ( |
distance.step |
Numeric, argument |
distance.step.x |
Numeric, argument |
distance.step.y |
Numeric, argument |
fill.color |
Character vector with hexadecimal codes (e.g. "#440154FF" "#21908CFF" "#FDE725FF"), or function generating a palette (e.g. |
line.color |
Character string, color of the line produced by |
seed |
Integer, random seed to facilitate reproduciblity. If set to a given number, the results of the function are always the same. Default: |
verbose |
Logical. If |
n.cores |
Integer, number of cores to use for parallel execution. Creates a socket cluster with |
cluster |
A cluster definition generated with |
A list with three slots:
comparison.df: Data frame with one performance value per spatial fold, metric, and model.
spatial.folds: List with the indices of the training and testing records for each evaluation repetition.
plot: Violin-plot of comparison.df.
rf_evaluate()
Other model_workflow:
rf_evaluate(),
rf_importance(),
rf_repeat(),
rf_tuning()
if(interactive()){
data(
plants_rf,
plants_rf_spatial,
plants_xy
)
comparison <- rf_compare(
models = list(
`Non spatial` = plants_rf,
Spatial = plants_rf_spatial
),
repetitions = 5,
xy = plants_xy,
metrics = "rmse",
n.cores = 1
)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.