Run random forest, returning only diagnostic values.
Source:R/make_rf_diagnostics.R
make_rf_diagnostics.RdRun random forest, returning only diagnostic values.
Usage
make_rf_diagnostics(
env_df,
clust_col = "cluster",
folds = 3L,
reps = 5L,
trees = 999,
down_sample = TRUE,
range_m = as.integer(seq(20000L, 100000L, length.out = reps)),
set_min = FALSE,
mlr3_cv_method = "repeated_cv",
coords = c("long", "lat"),
crs_df = 4283
)Arguments
- env_df
Dataframe with clusters and environmental columns.
- clust_col
Character. Name of column with cluster membership.
- folds
Numeric. How many folds to use in cross-validation?
- reps
Numeric. How many repeats of cross-validation?
- trees
Numeric. num.trees parameter in
mlr3::lrn()(with random classification forest usingranger::ranger()from package ranger).- down_sample
Logical or numeric. If TRUE, the
sample.fractionargument toranger::ranger()is set to the minimum number of sites in any one cluster divided by the total number of sites. If numeric, thesample.fractionargument varies per cluster asdown_sample / n_siteswheren_sitesis the number of sites in that cluster. In cases where any element is greater than 1, it is set to 1. IfFALSEthe defaultdown_sampleargument ofranger::ranger()is used.- range_m
Numeric. The distance in metres (regardless of the unit of the reference system of the input data) for block size(s) if using
blockCV::spatialBlock(). If reps > 1, an equivalent number of range_m values are required to ensure the folds are different between repetitions.repeated_spcv_block. Only needed if using spatial cross validation.- set_min
FALSE or numeric. If numeric, classes in
clust_colwith less thanset_mincases will be filtered.- mlr3_cv_method
Method to use with
mlr3::rsmp()(as character, e.g. "repeated_cv" or "repeated_spcv_block".- coords
Character vector of length 2. Names of columns in
env_dfwith x and y coordinates. Only needed if using spatial cross validation.- crs_df
Coordinate reference system for
coords. Passed to thecrsargument ofsf::st_as_sf(). Only needed if using spatial cross validation.