calculate_clustering_metrics {c2c}R Documentation

Calculate clustering metrics for a confusion matrix

Description

Calculate a range of clustering metrics on a confusion confusion matrix, usually from get_conf_mat.

Usage

calculate_clustering_metrics(conf_mat)

Arguments

conf_mat

a confusion matrix, as produced by get_conf_mat, or otherwise a confusion matrix of the same form.

Details

Entropy calculated via overall_entropy and class_entropy, purity calculated via overall_purity and class_purity, percentage agreement calculated via percentage_agreement (only for confusion matrices of equal dimensions and matching class order)

Value

A list containing the metrics that can be calculated, see details.

Author(s)

Mitchell Lyons

References

Lyons, Foster and Keith (2017). Simultaneous vegetation classification and mapping at large spatial scales. Journal of Biogeography.

See Also

get_conf_mat, labels_to_matrix, get_hard

Examples

# meaningless data, but you get the idea

# compare two soft classifications
my_soft_mat1 <- matrix(runif(50,0,1), nrow = 10, ncol = 5)
my_soft_mat2 <- matrix(runif(30,0,1), nrow = 10, ncol = 3)
# make the confusion matrix and calculate stats
conf_mat <- get_conf_mat(my_soft_mat1, my_soft_mat2)
conf_mat; calculate_clustering_metrics(conf_mat)

# compare a soft classificaiton to a vector of hard labels
my_labels <- rep(c("a","b","c"), length.out = 10)
# utilising labels_to_matrix(my_labels)
conf_mat <- get_conf_mat(my_soft_mat1, my_labels)
conf_mat; calculate_clustering_metrics(conf_mat)

# make one of the soft matrices hard
# utilising get_hard(my_soft_mat2)
conf_mat <- get_conf_mat(my_soft_mat1, my_soft_mat2, make.B.hard = TRUE)
conf_mat; calculate_clustering_metrics(conf_mat)

# two classifications with same number of classes, enables percentage agreement
conf_mat <- get_conf_mat(my_soft_mat1, my_soft_mat1)
conf_mat; calculate_clustering_metrics(conf_mat)


[Package c2c version 0.1.0 Index]