predict.tsvm_multiclass: Predict from a Multiclass Twin SVM

View source: R/ovo.R

predict.tsvm_multiclassR Documentation

Predict from a Multiclass Twin SVM

Description

Predicts from a one-vs-one multiclass twin SVM. Each binary model votes for one class. Ties are resolved deterministically by choosing the class that appears first in the training factor level order.

Usage

## S3 method for class 'tsvm_multiclass'
predict(object, newdata, type = c("class", "votes"), ...)

Arguments

object

A fitted tsvm_multiclass object.

newdata

Numeric matrix or data frame.

type

Output type. "class" returns predicted class labels; "votes" returns the vote matrix.

...

Unused. decision.values is not supported for multiclass objects because OVO decision values do not have a single unambiguous scale.

Value

A factor of predicted classes, or an integer vote matrix when type = "votes".

See Also

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

Examples

set.seed(40)
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")
predict(fit, x[1:3, , drop = FALSE])

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