Here is a quote from the help page of C5.0 (version 0.1.0-15):
The cost matrix should by CxC, where C is the number of classes. Diagonal elements are ignored. Columns should correspond to the true classes and rows are the predicted classes. For example, if C = 3 with classes Red, Blue and Green (in that order), a value of 5 in the (2,3) element of the matrix would indicate that the cost of predicting a Green sample as Blue is five times the usual value (of one).
Following the example in the help page, this would be a cost matrix:
cost.matrix <- matrix(c(
NA, 2, 4,
3, NA, 5,
7, 1, NA
), 3, 3, byrow=TRUE)
rownames(cost.matrix) <- colnames(cost.matrix) <- c("Red", "Blue", "Green")
cost.matrix
Red Blue Green
Red NA 2 4
Blue 3 NA 5
Green 7 1 NA
This would mean the following:
- Predicting a red sample as blue is 3 times the value as the usual value (one)
- Predicting a red sample as green is 7 times the value as the usual
- Predicting a blue sample as red is 2 times the ususal value
- Predicting a blue sample as green is 1 times the ususal value
- Predicting a green sample as red is 4 times the ususal value
- Predicting a green sample as blue is 5 times the usual value