train_model.Rd
This function is basically a wrapper around functionality from the CAST and caret packages. It expects as input a data.frame object with the predictors and outcome variables present and well as possible variables indicating the spatial and temporal sub-groups of the training data. Either one of the spatial or temporal variables can be used to create individual space or time folds
train_model( traindata, predictors, response, spacevar = NULL, timevar = NULL, k = 10, ffs = TRUE, method = "rf", metric = ifelse(is.factor(response) | is.character(response), "Accuracy", "RMSE"), maximize = ifelse(metric == "RMSE", FALSE, TRUE), trControl = caret::trainControl(), seed = 42, verbose = TRUE, ... )
traindata | A tibble, data.frame or sf object. |
---|---|
predictors | A character vector with the column names used as predictors. |
response | A character vector with the name of the response variable. |
spacevar | An optional character with a variable indicating spatial groups to account for during training. |
timevar | An optional character with a variable indicating temporal groups to account for during training. |
k | An integer value indicating the number of folds. Defaults to 10. |
ffs | A logical indicating if a Forward-Feature-Selection should be conducted. Note that this could significantly increase training time. |
method | A charachter vector indicating a model to be used by caret.
Defaults to |
metric | An accuracy metric for model optimization. Defaults to Accuracy for classification and RMSE for regression. Must be supported by caret. |
maximize | A logical indicating if the selected metric should be maximized. Defaults to TRUE for Accuracy and FALSE for RMSE. |
trControl | A train control object based on |
seed | An integer value used to ensure reproducibility. |
verbose | A logical indicating the level of verbosity. |
... |
A list with the model, performance metrics or confusion matrix (for regression or classification), a vector of observed values and a vector of predicted values.
Darius Görgen (MapTailor Geospatial Consulting GbR) info@maptailor.net
Maintainer: MAPME-Initiative contact@mapme-initiative.org
Contact Person: Dr. Johannes Schielein
Copyright: MAPME-Initiative
License: GPL-3