2

I would like to print simple table which will show how much rows in test set were predicted right and how much were wrong (true-negative, false-positive).

      |  class1   |   class2  |
class1|0.577995490|0.686545476|
class2|0.885664669|0.559988874|

(values in this table are not real)

I am currently using klaR package and NaiveBayes function which i use in predict() function. It looks like this:

prediction <- predict(naiveBayesSet, testSet)
4

2 回答 2

4

您可以使用table基础包中的函数来执行以下操作:

table(Predictions = prediction, TrueLabels = Labels)

其中 prediction 是上面代码中的向量,Labels 是其中包含真实标签的向量。

或者,您已经在使用errormatrix()的包中的功能可以做到这一点。klaR

于 2013-05-07T02:41:47.893 回答
3

caret包有一个confusionMatrix为此目的调用的函数:

require(caret)

confusionMatrix(prediction, reference)
于 2013-05-07T01:47:53.897 回答