Learn R Programming

optpart (version 3.0-3)

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’

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

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.

References

http://ecology.msu.montana.edu/labdsv/R

Examples

Run this code
# NOT RUN {
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)
# }

Run the code above in your browser using DataLab