Learn R Programming

twinsvm (version 0.0.1)

confusion: 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)

Value

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

Arguments

object

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

x

Numeric matrix or data frame of predictors.

y

True class labels.

See Also

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

Examples

Run this code
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)

Run the code above in your browser using DataLab