confusion: Confusion Matrix and Accuracy

View source: R/confusion.R

confusionR Documentation

Confusion Matrix and Accuracy

Description

Predicts on x and returns a confusion matrix plus overall accuracy. This works for both binary and one-vs-one multiclass tsvm and svms fits.

Usage

confusion(object, x, y)

Arguments

object

A fitted tsvm, tsvm_multiclass, svms, or svms_multiclass object.

x

Numeric matrix or data frame of predictors.

y

True class labels.

Value

A list with table, a table(truth, predicted) confusion matrix, and accuracy, the overall classification accuracy.

See Also

Other multiclass: predict.svms_multiclass(), predict.tsvm_multiclass(), print.svms_multiclass(), print.tsvm_multiclass()

Examples

set.seed(50)
x <- rbind(
  matrix(rnorm(20, -2, 0.2), ncol = 2),
  matrix(rnorm(20, 0, 0.2), ncol = 2),
  matrix(rnorm(20, 2, 0.2), ncol = 2)
)
y <- factor(rep(c("a", "b", "c"), each = 10))
fit <- tsvm(x, y, kernel = "linear")
confusion(fit, x, y)

twinsvm documentation built on June 10, 2026, 1:06 a.m.