statistics: Calculation of different performance measures and statistical...

View source: R/statistics.R

statisticsR Documentation

Calculation of different performance measures and statistical values

Description

statistics returns the different performance measures and statical values using the function confusionMatrix and the package pROC for the AUC-ROC calculation

Usage

statistics(pred, truth, positive, dnn, prevalence, mode)

Arguments

pred

factor containing the predicted classes

truth

factor containing the reference classes

positive

the first level of the factor or the level considered as positive class, if factors are classified as positive and negative classes

dnn

dimension names for the table

prevalence

prevalence should be a single numeric value since we are using the binary factors

mode

specifies either particular statistical values or everything returns all statistical values

Value

list containing two elements. First element is a list with elements: table (confusion matrix), positive (the level of positive class), overall (overall accuracy and other statistic values) and byClass (the values of different performance measures as specified by the argument mode). Second element is the value: Area under the curve

Examples

library(tm)
library(plyr)

truth <- factor(meta(liu_corpus)$real_label)
sam   <- meta(liu_corpus)$real_label
pred  <- factor(sample(sam))
statistics(pred, truth, positive = "1",  dnn = c("Prediction", "Truth"),
  prevalence = NULL, mode = "everything"
)

UBESP-DCTV/costumer documentation built on Feb. 1, 2023, 4:52 a.m.