becm_decision {ezECM} | R Documentation |
Outputs batch performance metrics of decisions using the output of predict.BayesECM()
when the true category of testing events are known. Can be used for empirically comparing different model fits.
becm_decision(
bayes_pred = NULL,
vic = NULL,
cat_truth = NULL,
alphatilde = 0.05,
pn = TRUE,
C = matrix(c(0, 1, 1, 0), ncol = 2),
rej = NULL
)
bayes_pred |
An object of class |
vic |
Character string, indicating the "Very Important Category" ( |
cat_truth |
Vector of the same length as |
alphatilde |
Numeric scalar between 0 and 1 used for the significance level of typicality indices. |
pn |
Logical. Acronym for "false Positive, false Negative". |
C |
Square matrix of dimension 2 or the number of categories. Used as the loss function in the decision theoretic framework. The default is 0-1 loss for binary categorization. |
rej |
|
The matrix C
specifies the loss for a set of categorization actions for a single new observation \tilde{y}_{\tilde{p}}
given the probability of \tilde{y}_{\tilde{p}}
belonging to each of K
categories. Actions are specified as the columns, and the event category random variables are specified as the rows. See the vignette vignette("syn-data-code", package = "ezECM")
for more mathematical details.
The dimension of matrix C
specifies the categorization type. A dimension of 2 is binary categorization, with the first column and row always corresponding to the category chosen as the vic
argument. Otherwise, when the dimension of C
is equal to the number of categories, the indices of the rows and columns of C
are in the same order as the categories listed for names(bayes_pred$BayesECMfit$Y)
.
A list of two data frames of logicals. The rows in each data frame correspond to the rows in bayes_pred$Ytilde
. The first data frame, named results
, has three columns named correct
, fn
, and fp
. The results
column indicates if the categorization is correct. fn
and fp
stand for false negatives and false positives respectively. fn
and fp
are found under binary categorization. Values of NA
are returned when a false positive or false negative is not relevant. The second data frame, named rej
, indicates the rejection of each new observation from each category via typicality index. One can use rej
to inspect if the typicality index played a role in categorization, or to supply to another call of becm_decision
.
csv_use <- "good_training.csv"
file_path <- system.file("extdata", csv_use, package = "ezECM")
training_data <- import_pvals(file = file_path, header = TRUE, sep = ",", training = TRUE)
trained_model <- BayesECM(Y = training_data, BT = c(10,1000))
csv_use <- "good_newdata.csv"
file_path <- system.file("extdata", csv_use, package = "ezECM")
new_data <- import_pvals(file = file_path, header = TRUE, sep = ",", training = TRUE)
bayespred <- predict(trained_model, Ytilde = new_data)
accuracy <- becm_decision(bayes_pred = bayespred, vic = "explosion", cat_truth = new_data$event)