Confusion matrix in R

Determine the accuracy of your landcover map

step 1: Install R on your computer

step 2: install the e1071 package in R.

install.packages("e1071")

Step 3: Use the confusion matrix algorithm as shown below.

library("e1071")

# your reference data
reference =  as.factor(c(1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4))
# values from your land cover map
prediction = as.factor(c(1,1,3,1,2,4,2,2,3,1,3,3,4,2,4,4))


# get the confusion table
confusionMatrix(prediction, reference, positive = NULL, dnn = c("Prediction", "Reference"))

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s