Description Usage Arguments Details Value Note Author(s) References Examples
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.
1 | confus(clustering,model,diss=NULL)
|
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’ |
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.
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 |
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.
David W. Roberts droberts@montana.edu http://ecology.msu.montana.edu/labdsv/R
http://ecology.msu.montana.edu/labdsv/R
1 2 3 4 5 6 7 8 9 | 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)
|
Loading required package: cluster
Loading required package: labdsv
Loading required package: mgcv
Loading required package: nlme
This is mgcv 1.8-33. For overview type 'help("mgcv-package")'.
This is labdsv 2.0-1
convert existing ordinations with as.dsvord()
Attaching package: ‘labdsv’
The following object is masked from ‘package:stats’:
density
Loading required package: MASS
Loading required package: plotrix
$confus
[,1] [,2] [,3] [,4] [,5]
[1,] 15 3 1 0 0
[2,] 6 42 6 1 1
[3,] 2 9 21 1 1
[4,] 1 2 5 7 3
[5,] 1 3 0 0 19
$correct
[1] 104
$percent
[1] 0.6933333
$kappa
[1] 0.5913533
$confus
[,1] [,2] [,3] [,4] [,5]
[1,] 17.3726945 1.144038 0.483268 0.0000000 0.0000000
[2,] 3.9606226 47.976570 2.430329 0.8834618 0.7490170
[3,] 1.4093234 3.429740 27.653490 0.8330640 0.6743818
[4,] 0.7836742 1.412361 2.977090 11.6709577 1.1559174
[5,] 0.8902513 2.245041 0.000000 0.0000000 19.8647074
$correct
[1] 124.5384
$percent
[1] 0.8302561
$kappa
[1] 0.7752168
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.