tsvm: Fit a Twin Support Vector Machine

View source: R/tsvm.R

tsvmR Documentation

Fit a Twin Support Vector Machine

Description

Fits a twin support vector machine. With two classes this uses the validated binary twin-SVM path: level 1 of y is class B, level 2 is class A, plane 1 is close to class A, and plane 2 is close to class B. With three or more classes, the function fits one binary twin SVM for each class pair and predicts by majority vote. Multiclass ties are resolved by choosing the class that appears first in the factor level order.

Usage

tsvm(
  x,
  y,
  method = c("ls", "twin"),
  kernel = c("linear", "rbf", "poly"),
  c1 = 1,
  c2 = 1,
  gamma = NULL,
  degree = 3,
  coef0 = 1,
  eps = 1e-06
)

Arguments

x

Numeric matrix or data frame of predictors.

y

Response with at least two classes.

method

Twin-SVM method. "ls" fits least-squares twin SVM; "twin" fits the original box-constrained dual formulation.

kernel

Kernel name.

c1, c2

Positive regularization parameters.

gamma

Kernel scale. Defaults to 1 / ncol(x).

degree

Polynomial degree.

coef0

Polynomial offset.

eps

Ridge term added to every linear solve.

Value

A fitted tsvm object for two classes, or a tsvm_multiclass object for three or more classes.

References

Jayadeva, Khemchandani, R., and Chandra, S. (2007). Twin support vector machines for pattern classification. IEEE Transactions on Pattern Analysis and Machine Intelligence, 29(5), 905-910.

Kumar, M. A. and Gopal, M. (2009). Least squares twin support vector machines for pattern classification. Expert Systems with Applications, 36(4), 7535-7543.

Examples

set.seed(3)
dat <- gen_moons(50, noise = 0.05)
fit <- tsvm(dat$x, dat$y)
predict(fit, dat$x[1:4, ])

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