How to calculate the specificity, sensitivity and accuracy from the 4 factors

Used decision tree method. Created treemodel for the combined datasets and tried to make prediction on test datasets to calculate error. Below is the code and output. Please help me on how to calculate the specificity, sensitivity and accuracy from the four status. The following are the status.

'A' stands for contract finished, no problems
'B' stands for contract finished, loan not payed
'C' stands for running contract, OK thus-far
'D' stands for running contract, client in debt

train.pred <- predict(treemodel,testdata, type="class")
table(train.pred, testdata$status)

train.pred A B C D
A 39140 3540 0 0
B 457 2227 0 145
C 61 0 44686 5522
D 0 0 0 0

I've been using Max Kuhn's yardstick package for this sort of thing lately:

2 Likes