rpart
rpart copied to clipboard
How to specify a loss matrix in rpart?
Cost for mis-classification can be used as below:
fit <- rpart(target ~ ., data=dataset, method="class", parms=list(loss=matrix(c(0,1,2,0), byrow=TRUE, nrow=2)))
If there are two class A and B, the loss of A wrongly judged as B is 1, and the loss of B wrongly judged as A is 2, how to set the loss matrix?
Horizontal is the actual value, vertical is the judgment value
loss=matrix(c(0,1,2,0), byrow=TRUE, nrow=2))