pairs2svmData: pairs2svmData

Description Usage Arguments Value Author(s) Examples

Description

We do several preprocessing steps on the input data:

  1. centering and scaling.

  2. for all pairs i such that yi=-1, we flip Xi and Xip and set yi=1.

  3. for all pairs i such that yi=0, we generate new features Xi <- Xip and Xip <- Xi with corresponding new yi=0 labels.

  4. We take the difference Xip-Xi of the resulting scaled, flipped, augmented feature matrices.

  5. We map 0 -> -1 in the resulting label vector, creating an integer vector with elements in c(-1,1).

Usage

1

Arguments

Pairs

Value

data suitable for plugging into an SVM solver:

center

center of the input features.

scale

scale of input features.

Xi

inputs feature matrix.

Xip

inputs feature matrix.

yi

outputs -1 -> 1, 0 -> -1, 1 -> 1.

Author(s)

Toby Dylan Hocking

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
p <- list(Xi=cbind(var=c(3,0,1)),
          Xip=cbind(var=c(0,-2,0)),
          yi=as.integer(c(-1,1,0)))
(result <- pairs2svmData(p))
## Inequality pairs such that yi=1 or -1 are mapped to 1, and
## equality pairs such that yi=0 are duplicated and mapped to -1.
stopifnot(result$labels == c(1,1,-1,-1))
## The duplicate equality features are flipped.
stopifnot(result$Xi[3]==result$Xip[4])
stopifnot(result$Xi[4]==result$Xip[3])

tdhock/rankSVMcompare documentation built on May 31, 2019, 7:38 a.m.