Learn R Programming

HRTnomaly (version 25.11.22)

print.checkwise: A Method to Print the Accuracy of Outlier Classification Results

Description

The function prints the confusion matrix and accuracy results previously computed with the function class_check.

Usage

# S3 method for checkwise
print(x, confusion = FALSE, ...)

Value

An S3 class named checkwise with the confusion matrix, and other accuracy metrics appended as attribues.

attr(, "overall") A numeric value between zero and one with the overall accuracy.

attr(, "recall") A numeric vector of values between zero and one with the recall index for regular and outlier cells.

attr(, "precision") A numeric vector of values between zero and one with the precision index for regular and outlier cells.

attr(, "f1-score") A numeric vector of values between zero and one with the F1-scores for regular and outlier cells.

Arguments

x

An S3 object of the class checkwise, typically computed with the function class_check.

confusion

A logical value, which is FALSE by default. If TRUE, the confusion matrix is printed after showing all accuracy metrics.

...

Additional arguments to pass to the function cat.

Author

Luca Sartore drwolf85@gmail.com

Details

The function computes the confusion matrix using the function table. True positive and false negative are successively evaluated to compute overall accuracy, recall, precision, and F1-scores.

Examples

Run this code
if (FALSE) {
# Load the package
library(HRTnomaly)
set.seed(2025L)
# Load the 'toy' data
data(toy)
# Detect cellwise outliers using Bayesian Analysis
res <- cellwise(toy[sample.int(100), ], 0.5, 10L)
class_check(res$outlier, res$anomaly_flag != "")
}

Run the code above in your browser using DataLab