# NOT RUN {
# read a tibble with 400 samples of Cerrado and 346 samples of Pasture
data(cerrado_2classes)
# perform a 2 fold validation of this sample file
pred_ref <- sits_kfold_validate(cerrado_2classes,
folds = 2,
ml_method = sits_rfor(num_trees = 300)
)
# calculate and print the confusion matrix
conf <- sits_conf_matrix(pred_ref)
# create a list to store the results
results <- list()
# give a name to the confusion matrix
conf$name <- "confusion_matrix"
# add the confusion matrix to the results
results[[length(results) + 1]] <- conf
# save the results to an XLSX file
xlsx_file <- paste0(tempdir(), "confusion_matrix.xlsx")
sits_to_xlsx(results, file = xlsx_file)
# }
Run the code above in your browser using DataLab