Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

confus

(Fuzzy) Confusion Matrix


Description

A confusion matrix is a cross-tabulation of actual class membership with memberships predicted by a discriminant function, classification tree, or other predictive model. A fuzzy confusion matrix is a confusion matrix that corrects for ‘near misses’ in prediction by comparing the similarity of the predicted type to the actual type and giving credit for the similarity.

Usage

confus(clustering,model,diss=NULL)

Arguments

clustering

an object of class ‘clustering’ or a vector of (integer or factor) class membership values

model

a predictive model of class ‘tree’ or ‘randomForest’

diss

optionally, a dissimilarity object of class ‘dist’ from ‘dist’, ‘dsvdis’, or ‘vegdist’

Details

Cross-classifies each sample by actual class membership and predicted membership, computing overall accuracy, and the Kappa statistic of agreement. If a dissimilarity matrix is passed, calculates a fuzzy confusion matrix. In this case, correct predictions are assigned values of 1.0, and other predictions are given the value of the similarity of the two types an placed on the diagonal. The dissimilarity of the two types is added off the diagonal as fuzzy error.

Value

produces a list with elements

matrix

the (fuzzy) cross-tabulation matrix as a data.frame

correct

the fraction of (fuzzily) correctly predicted samples

kappa

the value of the Kappa statistic

legend

the text legend for the cross-tabulation matrix

Note

Confusion matrices are commonly computed in remote sensing applications, but are equally suited to the evaluation of any predictive methods of class membership or factors.

Author(s)

References

Examples

data(shoshveg) # returns a data frame of vegetation data
data(shoshsite) # returns a data frame of site data
dis.bc <- dsvdis(shoshveg,'bray')
opt.5 <- optpart(5,dis.bc)
library(tree)
mod <- tree(factor(opt.5$clustering)~ elevation+slope+av,
            data=shoshsite)
confus(opt.5,mod)
confus(opt.5,mod,dis.bc)

optpart

Optimal Partitioning of Similarity Relations

v3.0-3
GPL (>= 2)
Authors
David W. Roberts <droberts@montana.edu>
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.