I have googled much in the web, but don't find any useful description for the 'costs' parameter for C5.0 function in R. From the C5.0 R manual book, it just says "a matrix of costs associated with the possible errors. The matrix should have C columns and rows where C is the number of class levels". It does not tell me whether the row or the column is the predicated result by the model.
Can anyone help?
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With