Description Usage Arguments Value Author(s) Examples
We do several preprocessing steps on the input data:
centering and scaling.
for all pairs i such that yi=-1, we flip Xi and Xip and set yi=1.
for all pairs i such that yi=0, we generate new features Xi <- Xip and Xip <- Xi with corresponding new yi=0 labels.
We take the difference Xip-Xi of the resulting scaled, flipped, augmented feature matrices.
We map 0 -> -1 in the resulting label vector, creating an integer vector with elements in c(-1,1).
1 | pairs2svmData(Pairs)
|
Pairs |
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. |
Toby Dylan Hocking
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])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.