Category:Model Evaluation: accuracy and/or error

1.) How to check the accuracy of a prediction?  This is useful for ZeroR, OneR or other model predictions.
accuracy <- function(truth, prediction) { tbl <- table(truth, prediction) sum(diag(tbl)) / sum(tbl) } # Michael Hahslers Intro to Data Mining
 * 1) use the function for accuracy

2.) Another implementation for finding accuracy:
> accuracy <- sum(classifierResults == testData$Target)/dim(testData)[1]

3.) Calculate Confusion matrix, accuracy, precision and recall:
From, library(caret), use table and confusionMatrix. For example: xtab <- table(predicted_class, original_class) confusionMatrix(xtab)