svm_poly: General interface for polynomial support vector machines

Description Usage Arguments Details Engine Details See Also Examples

View source: R/svm_poly.R

Description

svm_poly() is a way to generate a specification of a model before fitting and allows the model to be created using different packages in R or via Spark. The main arguments for the model are:

These arguments are converted to their specific names at the time that the model is fit. Other options and argument can be set using set_engine(). If left to their defaults here (NULL), the values are taken from the underlying model functions. If parameters need to be modified, update() can be used in lieu of recreating the object from scratch.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
svm_poly(
  mode = "unknown",
  cost = NULL,
  degree = NULL,
  scale_factor = NULL,
  margin = NULL
)

## S3 method for class 'svm_poly'
update(
  object,
  parameters = NULL,
  cost = NULL,
  degree = NULL,
  scale_factor = NULL,
  margin = NULL,
  fresh = FALSE,
  ...
)

Arguments

mode

A single character string for the type of model. Possible values for this model are "unknown", "regression", or "classification".

cost

A positive number for the cost of predicting a sample within or on the wrong side of the margin

degree

A positive number for polynomial degree.

scale_factor

A positive number for the polynomial scaling factor.

margin

A positive number for the epsilon in the SVM insensitive loss function (regression only)

object

A polynomial SVM model specification.

parameters

A 1-row tibble or named list with main parameters to update. If the individual arguments are used, these will supersede the values in parameters. Also, using engine arguments in this object will result in an error.

fresh

A logical for whether the arguments should be modified in-place of or replaced wholesale.

...

Not used for update().

Details

The model can be created using the fit() function using the following engines:

Engine Details

Engines may have pre-set default arguments when executing the model fit call. For this type of model, the template of the fit calls are below:

kernlab

svm_poly() %>% 
  set_engine("kernlab") %>% 
  set_mode("regression") %>% 
  translate()
1
2
3
4
5
6
## Polynomial Support Vector Machine Specification (regression)
## 
## Computational engine: kernlab 
## 
## Model fit template:
## kernlab::ksvm(x = missing_arg(), data = missing_arg(), kernel = "polydot")
svm_poly() %>% 
  set_engine("kernlab") %>% 
  set_mode("classification") %>% 
  translate()
1
2
3
4
5
6
7
## Polynomial Support Vector Machine Specification (classification)
## 
## Computational engine: kernlab 
## 
## Model fit template:
## kernlab::ksvm(x = missing_arg(), data = missing_arg(), kernel = "polydot", 
##     prob.model = TRUE)

fit() passes the data directly to kernlab::ksvm() so that its formula method can create dummy variables as-needed.

Parameter translations

The standardized parameter names in parsnip can be mapped to their original names in each engine that has main parameters. Each engine typically has a different default value (shown in parentheses) for each parameter.

parsnip kernlab
cost C (1)
degree degree (1)
scale_factor scale (1)
margin epsilon (0.1)

See Also

fit()

Examples

1
2
3
4
5
6
7
svm_poly(mode = "classification", degree = 1.2)
# Parameters can be represented by a placeholder:
svm_poly(mode = "regression", cost = varying())
model <- svm_poly(cost = 10, scale_factor = 0.1)
model
update(model, cost = 1)
update(model, cost = 1, fresh = TRUE)

parsnip documentation built on July 8, 2020, 7:22 p.m.