Learn R Programming

sits (version 1.12.0)

sits_conf_matrix: Assessment of the accuracy of classification based on a confusion matrix

Description

Evaluates the confusion matrix based on "reference" and "predicted" values provided in a sits tibble that has been classified. This function takes two kinds of input: (a) The output of the sits_classify function (a tibble with a list of predicted values) (b) The output of the sits_kfold_validate function (a tibble with two columns - predicted and reference) This function returns the Overall Accuracy, User's Accuracy, Producer's Accuracy, error matrix (confusion matrix), and Kappa value.

Usage

sits_conf_matrix(class.tb, conv.lst = NULL, pred_sans_ext = FALSE)

Arguments

class.tb

A tibble containing a set of classified samples whose labels are known.

conv.lst

List with labels to be converted. If NULL no conversion is done.

pred_sans_ext

A logical value: remove all label extension? (i.e. every string after last '.' character) from predictors before compute assesment.

Value

A confusion matrix assessment produced by the caret package.

Examples

Run this code
# 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.tb <- sits_kfold_validate(cerrado_2classes, folds = 2)
# calculate and print the confusion matrix
conf.mx <- sits_conf_matrix(pred_ref.tb)
# }

Run the code above in your browser using DataLab