| svms | R Documentation |
Fits a C-SVC support vector machine with a Platt SMO solver. With two classes this uses the validated binary path. With three or more classes, the function fits one binary 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.
svms(
x,
y,
kernel = c("linear", "rbf", "poly"),
cost = 1,
gamma = NULL,
degree = 3,
coef0 = 1,
tol = 0.001,
max_passes = 10L,
max_iter = 10000L
)
x |
Numeric matrix or data frame of predictors. |
y |
Response with at least two classes. In the binary path, level 1 is the negative class and level 2 is the positive class. |
kernel |
Kernel name: |
cost |
Positive C-SVC cost parameter. |
gamma |
Kernel scale. Defaults to |
degree |
Polynomial degree. |
coef0 |
Polynomial offset. |
tol |
SMO tolerance. |
max_passes |
Maximum consecutive passes without alpha changes. |
max_iter |
Maximum SMO iterations. |
A fitted svms object for two classes, or a svms_multiclass object
for three or more classes.
set.seed(1)
dat <- gen_moons(40, noise = 0.1)
fit <- svms(dat$x, dat$y, kernel = "linear", cost = 1)
predict(fit, dat$x[1:3, ])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.