For this engine, there are multiple modes: classification and regression
This model has 2 tuning parameters:
cost
: Cost (type: double, default: 1.0)
margin
: Insensitivity Margin (type: double, default: no default)
This engine fits models that are L2-regularized for L2-loss. In the [LiblineaR::LiblineaR()] documentation, these are types 1 (classification) and 11 (regression).
Parsnip changes the default range for cost
to c(-10, 5)
.
svm_linear(
cost = double(1),
margin = double(1)
) %>%
set_engine("LiblineaR") %>%
set_mode("regression") %>%
translate()
## Linear Support Vector Machine Model Specification (regression)
##
## Main Arguments:
## cost = double(1)
## margin = double(1)
##
## Computational engine: LiblineaR
##
## Model fit template:
## LiblineaR::LiblineaR(x = missing_arg(), y = missing_arg(), C = double(1),
## svr_eps = double(1), type = 11)
svm_linear(
cost = double(1)
) %>%
set_engine("LiblineaR") %>%
set_mode("classification") %>%
translate()
## Linear Support Vector Machine Model Specification (classification)
##
## Main Arguments:
## cost = double(1)
##
## Computational engine: LiblineaR
##
## Model fit template:
## LiblineaR::LiblineaR(x = missing_arg(), y = missing_arg(), C = double(1),
## type = 1)
The margin
parameter does not apply to classification models.
Note that the LiblineaR
engine does not produce class probabilities. When optimizing the model using the tune package, the default metrics require class probabilities. To use the tune_*()
functions, a metric set must be passed as an argument that only contains metrics for hard class predictions (e.g., accuracy).
Factor/categorical predictors need to be converted to numeric values (e.g., dummy or indicator variables) for this engine. When using the formula method via \code{\link[=fit.model_spec]{fit()}}, parsnip will convert factor columns to indicators.
Predictors should have the same scale. One way to achieve this is to center and scale each so that each predictor has mean zero and a variance of one.
The underlying model implementation does not allow for case weights.
This model can utilize sparse data during model fitting and prediction. Both sparse matrices such as dgCMatrix from the Matrix
package and sparse tibbles from the sparsevctrs
package are supported. See [sparse_data] for more information.
The "Fitting and Predicting with parsnip" article contains examples for svm_linear()
with the "LiblineaR"
engine.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.