Learn R Programming

labdsv (version 1.2-0)

confus: 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.

Usage

confus(class,fitted)

Arguments

class
a vector of (integer) class membership values
fitted
a matrix of predicted class memberships

Value

  • produces a list with elements
  • matrixthe cross-tabulation matrix
  • correctthe fraction of correctly predicted samples
  • kappathe value of the Kappa statistic
  • legendthe 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.

References

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

Examples

Run this code
data(bryceveg) # returns a data frame of vegetation data
    data(brycesite)
    library(tree)
    mod <- tree(factor(bryceveg$arcpat>0)~ elev+slope+av,data=brycesite)
    pred <- predict(mod,newdata=brycesite)
    confus(bryceveg$arcpat>0,pred)

Run the code above in your browser using DataLab