Reputation: 43
In the R help page for confusionMatrix() in the caret package there is this 3 class example:
confusionMatrix(iris$Species, sample(iris$Species))
newPrior <- c(.05, .8, .15)
names(newPrior) <- levels(iris$Species)
confusionMatrix(iris$Species, sample(iris$Species))
How is the newPrior value getting incorporated into the Confusion Matrix?
Upvotes: 0
Views: 59
Reputation: 4949
In this example, newPrior
is not included in the error confusion matrices in any way!!
You may have been confused that the two matrices are different. However, this is due to the pseudo-random nature of the sample
function. If you add the grain alignment before each call, you will find that in both cases the confusion matrices are identical!
library(caret)
set.seed(123)
cf1 = confusionMatrix(iris$Species, sample(iris$Species))
newPrior <- c(.05, .8, .15)
names(newPrior) <- levels(iris$Species)
set.seed(123)
cf2 = confusionMatrix(iris$Species, sample(iris$Species))
identical(cf1, cf2)
output
[1] TRUE
Upvotes: 1