Description Usage Arguments Value Author(s) References See Also Examples

Carries out a support vector machine classification of new data using the output of `vcr.svm.train`

on the training data, and computes the quantities needed for its visualization.

1 | ```
vcr.svm.newdata(Xnew, ynew=NULL, vcr.svm.train.out)
``` |

`Xnew` |
data matrix of the new data, with the same number of columns as in the training data. Missing values in |

`ynew` |
factor with class membership of each new case. Can be |

`vcr.svm.train.out` |
output of |

A list with components:

`yintnew` |
number of the given class of each case. Can contain |

`ynew` |
given class label of each case. Can contain |

`levels` |
levels of the response, from |

`predint` |
predicted class number of each case. Always exists. |

`pred` |
predicted label of each case. |

`altint` |
number of the alternative class. Among the classes different from the given class, it is the one with the highest posterior probability. Is |

`altlab` |
alternative label if yintnew was given, else |

`PAC` |
probability of the alternative class. Is |

`figparams` |
(from training data) parameters used for |

`fig` |
distance of each case |

`farness` |
farness of each case from its given class. Is |

`ofarness` |
for each case |

Raymaekers J., Rousseeuw P.J.

Raymaekers J., Rousseeuw P.J., Hubert M. (2021). Class maps for visualizing
classification results. *Technometrics*, forthcoming. (link to open access pdf)

`vcr.svm.train`

, `classmap`

, `e1071::svm`

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | ```
library(e1071)
set.seed(1); X = matrix(rnorm(200*2),ncol=2)
X[1:100,] = X[1:100,]+2
X[101:150,] = X[101:150,]-2
y = as.factor(c(rep("blue",150),rep("red",50)))
# We now fit an SVM with radial basis kernel to the data:
set.seed(1) # to make the result of svm() reproducible.
svmfit = svm(y~.,data=data.frame(X=X,y=y),scale=FALSE,kernel="radial",
cost=10, gamma=1, probability=TRUE)
vcr.train = vcr.svm.train(X, y, svfit=svmfit)
# As "new" data we take a subset of the training data:
inds = c(1:25,101:125,151:175)
vcr.test = vcr.svm.newdata(X[inds,],y[inds],vcr.train)
plot(vcr.test$PAC,vcr.train$PAC[inds]); abline(0,1) # match
plot(vcr.test$farness,vcr.train$farness[inds]); abline(0,1)
confmat.vcr(vcr.test)
cols = c("deepskyblue3","red")
stackedplot(vcr.test, classCols = cols)
classmap(vcr.train, "blue", classCols = cols) # for comparison
classmap(vcr.test, "blue", classCols = cols)
classmap(vcr.train, "red", classCols = cols) # for comparison
classmap(vcr.test, "red", classCols = cols)
# For more examples, we refer to the vignettes:
vignette("Support_vector_machine_examples")
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.