View source: R/train_mark_model.R
| train_mark_model | R Documentation |
Trains a predictive model for the mark distribution of a spatio-temporal process.
data may be either (1) a data.frame containing columns x, y, size and time,
(2) a data.frame containing x, y, size (time will be derived via delta),
or (3) a ldmppr_fit object returned by estimate_process_parameters.
Allows the user to incorporate location specific information and competition indices as covariates in the mark model.
train_mark_model(
data,
raster_list = NULL,
scaled_rasters = FALSE,
model_type = "xgboost",
xy_bounds = NULL,
delta = NULL,
save_model = FALSE,
save_path = NULL,
parallel = FALSE,
num_cores = NULL,
include_comp_inds = FALSE,
competition_radius = 15,
edge_correction = "none",
selection_metric = "rmse",
cv_folds = 5,
tuning_grid_size = 200,
seed = 0,
verbose = TRUE
)
data |
a data.frame or a |
raster_list |
list of raster objects used for mark-model training. |
scaled_rasters |
|
model_type |
the machine learning model type ( |
xy_bounds |
a vector of domain bounds (2 for x, 2 for y). If |
delta |
(optional) numeric scalar used only when |
save_model |
|
save_path |
path for saving the generated model. |
parallel |
|
num_cores |
number of workers to use when |
include_comp_inds |
|
competition_radius |
positive numeric distance used when |
edge_correction |
type of edge correction to apply ( |
selection_metric |
metric to use for identifying the optimal model ( |
cv_folds |
number of cross-validation folds to use in model training.
If |
tuning_grid_size |
size of the tuning grid for hyperparameter tuning. |
seed |
integer seed for reproducible resampling/tuning/model fitting. |
verbose |
|
an object of class "ldmppr_mark_model" containing the trained mark model.
# Load the small example data
data(small_example_data)
# Load example raster data
raster_paths <- list.files(system.file("extdata", package = "ldmppr"),
pattern = "\\.tif$", full.names = TRUE
)
raster_paths <- raster_paths[!grepl("_med\\.tif$", raster_paths)]
rasters <- lapply(raster_paths, terra::rast)
# Scale the rasters
scaled_raster_list <- scale_rasters(rasters)
# Train the model
mark_model <- train_mark_model(
data = small_example_data,
raster_list = scaled_raster_list,
scaled_rasters = TRUE,
model_type = "xgboost",
xy_bounds = c(0, 25, 0, 25),
delta = 1,
parallel = FALSE,
include_comp_inds = FALSE,
competition_radius = 10,
edge_correction = "none",
selection_metric = "rmse",
cv_folds = 3,
tuning_grid_size = 2,
verbose = TRUE
)
print(mark_model)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.