2

Assuming "test" and "train" are two data frames for testing and traininig respectively, and "model" is a classifier that was generated using training data. I can find the number of misclassified examples like this:

n = sum(test$class_label != predict(model, test))

How can I find the number of examples that is predicted as negative but it is actually positive? (i.e. false positive)

NOTE: Above example assumes that the problem is a binary classification problem whose classes are, say, "yes" (positive class) and "no". Additionally, predict is a function of caret package.

Ricardo Cristian Ramirez
  • 1,194
  • 3
  • 20
  • 42

1 Answers1

5

This will get you a 2x2 table showing true positives, false positives, false negatives and true negatives.

> table(Truth = test$class_label, Prediction = predict(model, test))

     Prediction
Truth yes no
  yes  32  3
  no    8 27
Backlin
  • 14,612
  • 2
  • 49
  • 81