confusionMAT: create a confusion matrix

View source: R/confusionMAT.R

confusionMATR Documentation

create a confusion matrix

Description

The function populates a confusion matrix using predicted and reference points and estimate the errors in commission, omissioin for each class, in addition to Producer, User and overall accuracy, and the Kappa Coefficient. Errors in Commission provide a measure of false negatives i.e. the number of points that were predicted to be part of a class that they were not (probability something was incorrectly classified FN/(TP+FN)). Errors in Omission provide a measure of false positives that were predicted to be in a different class from their actual class (probability that something was missed FP/(FP +TP). User Accuracy or Recall represents the probability that a class was correctly classified TP/(TP + FN). Producer Accuracy or Precision provides a measure of how likely something was missed by the classification (probability that something was not missed TP/(TP + FP)). The Overall Accuracy represents the probability that all classes were correctly classified (TP+TN)/(TP+TN+FP+FN). Finally, the Kappa Coefficient measures the agreement between the classification and the truth ((TN+FP) (TN+FN) + (FN+TP) (FP+TP)) / (TP+FP+TN+FN)2

Usage

confusionMAT(reference, classified)

Arguments

reference

Reference dataset wich classification is to be compared to

classified

Classification output to compare with a reference dataset

Value

a confusion matrix

References

Congalton, R.G. and Green, K., 2008. Assessing the accuracy of remotely sensed data: principles and practices. CRC press.

Examples


## Get hoopoe data and crop where appropriate
#data("hoopoe")
#start = as.POSIXct("2016-08-01","%Y-%m-%d", tz="UTC")
#end = as.POSIXct("2017-05-15","%Y-%m-%d", tz="UTC")
#PAM_data = cutPAM(hoopoe, start, end)

## Generate a classification from activity
#activity_classification = classifyFLAP(PAM_data$acceleration, period = 10)
#reference = activity_classification$classification
#reference[reference != activity_classification$migration] = "Not Migrating"
#reference[(activity_classification$classification ==
#          activity_classification$high_movement)] = "Flying"
#reference[reference == activity_classification$migration] = "Migrating"

## Generate a very simple pressure classification based on pressure changes
#classified  = ifelse( abs(diff(PAM_data$pressure$obs)) >2, "Migrating", "Not Migrating")

## Remove dates from activity which are not also present in pressure
#to_keep = which(PAM_data$acceleration$date %in% PAM_data$pressure$date)
#reference = reference[to_keep]
#reference = reference[-1]

#confusionMAT(reference, classified)


KiranLDA/PAMLr documentation built on March 6, 2023, 1:40 p.m.