cross_validate_model: Cross-validation for BART model

View source: R/bart_functions.R

cross_validate_modelR Documentation

Cross-validation for BART model

Description

This function performs cross-validation for a Bayesian Additive Regression Trees (BART) model using presence-absence data and environmental covariate layers. It calculates various performance metrics for model evaluation.

Usage

cross_validate_model(data, folds, predictor_cols = NULL, seed = NULL)

Arguments

data

Data frame with a column (named 'pa') indicating presence (1) or absence (0) and columns for the predictor variables.

folds

A vector of fold assignments (same length as 'data').

predictor_cols

Optional; a character vector of column names to be used as predictors. If NULL, all columns except 'pa' will be used.

seed

Optional; random seed.

Value

A list with:

metrics

A data frame containing the true positives (TP), false positives (FP), false negatives (FN), true negatives (TN), and various performance metrics including precision (PREC), sensitivity (SEN), specificity (SPC), false discovery rate (FDR), negative predictive value (NPV), false negative rate (FNR), false positive rate (FPR), F-score, accuracy (ACC), balanced accuracy (BA), and true skill statistic (TSS) for each fold.

predictions

Data frame with observed, predicted, probability, and fold assignment per test instance.


glossa documentation built on June 8, 2025, 1:20 p.m.