Skip to content

Commit 481fb09

Browse files
authored
Merge pull request #425 from tidymodels/deprecate-liquidsvm
Soft deprecate liquidSVM engine
2 parents ed9e705 + a062714 commit 481fb09

File tree

7 files changed

+14
-205
lines changed

7 files changed

+14
-205
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Imports:
2424
tibble (>= 2.1.1),
2525
generics (>= 0.1.0),
2626
glue,
27+
lifecycle,
2728
magrittr,
2829
stats,
2930
tidyr (>= 1.0.0),
@@ -51,5 +52,4 @@ Suggests:
5152
MASS,
5253
nlme,
5354
modeldata,
54-
liquidSVM,
5555
Matrix

NEWS.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
# parsnip (development version)
2+
3+
* The `liquidSVM` engine for `svm_rbf()` was deprecated due to that package's removal from CRAN.
4+
15
# parsnip 0.1.5
26

3-
* An RStudio add-in is availble that makes writing multiple `parsnip` model specifications to the source window. It can be accessed via the IDE addin menus or by calling `parsnip_addin()`.
7+
* An RStudio add-in is available that makes writing multiple `parsnip` model specifications to the source window. It can be accessed via the IDE addin menus or by calling `parsnip_addin()`.
48

59
* For `xgboost` models, users can now pass `objective` to `set_engine("xgboost")`. (#403)
610

R/engines.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ set_engine <- function(object, engine, ...) {
9393
}
9494
if (!is.character(engine) | length(engine) != 1)
9595
rlang::abort("`engine` should be a single character value.")
96+
if (engine == "liquidSVM") {
97+
lifecycle::deprecate_soft(
98+
"0.1.6",
99+
"set_engine(engine = 'cannot be liquidSVM')",
100+
details = "The liquidSVM package is no longer available on CRAN.")
101+
}
96102

97103
object$engine <- engine
98104
object <- check_engine(object)

R/svm_rbf.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#' following _engines_:
3434
#' \itemize{
3535
#' \item \pkg{R}: `"kernlab"` (the default)
36-
#' \item \pkg{R}: `"liquidSVM"`
3736
#' }
3837
#'
3938
#'

man/rmd/svm-rbf.Rmd

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,6 @@ svm_rbf() %>%
2424

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

27-
## liquidSVM
28-
29-
```{r liquidSVM-reg}
30-
svm_rbf() %>%
31-
set_engine("liquidSVM") %>%
32-
set_mode("regression") %>%
33-
translate()
34-
```
35-
36-
```{r liquidSVM-cls}
37-
svm_rbf() %>%
38-
set_engine("liquidSVM") %>%
39-
set_mode("classification") %>%
40-
translate()
41-
```
42-
43-
Note that models created using the `liquidSVM` engine cannot be saved like
44-
conventional R objects. The `fit` slot of the `model_fit` object has to be saved
45-
separately using the `liquidSVM::write.liquidSVM()` function. Likewise to restore
46-
a model, the `fit` slot has to be replaced with the model that is read using the
47-
`liquidSVM::read.liquidSVM()` function.
48-
49-
`liquidSVM` parameterizes the kernel parameter differently than `kernlab`. To
50-
translate between engines, `sigma = 1/gammas^2`. Users will be specifying
51-
`sigma` and the function translates the value to `gamma`.
52-
53-
`fit()` passes the data directly to `liquidSVM::svm()` so that its formula method can create dummy variables as-needed.
54-
5527
## Parameter translations
5628

5729
The standardized parameter names in parsnip can be mapped to their original
@@ -66,8 +38,6 @@ get_defaults_svm_rbf <- function() {
6638
"svm_rbf", "kernlab", "cost", "C", "1",
6739
"svm_rbf", "kernlab", "rbf_sigma", "sigma", "varies",
6840
"svm_rbf", "kernlab", "margin", "epsilon", "0.1",
69-
"svm_rbf", "liquidSVM", "cost", "lambdas", "varies",
70-
"svm_rbf", "liquidSVM", "rbf_sigma", "gammas", "varies",
7141
)
7242
}
7343
convert_args("svm_rbf")

man/svm_rbf.Rd

Lines changed: 2 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test_svm_liquidsvm.R

Lines changed: 0 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -79,132 +79,3 @@ test_that('bad input', {
7979
expect_error(svm_rbf(mode = "reallyunknown"))
8080
expect_error(translate(svm_rbf() %>% set_engine( NULL)))
8181
})
82-
83-
# ------------------------------------------------------------------------------
84-
# define model specification for classification and regression
85-
86-
reg_mod <-
87-
svm_rbf(rbf_sigma = .1, cost = 0.25) %>%
88-
set_engine("liquidSVM", random_seed = 1234, folds = 1, max_gamma=500) %>%
89-
set_mode("regression")
90-
91-
cls_mod <-
92-
svm_rbf(rbf_sigma = .1, cost = 0.125) %>%
93-
set_engine("liquidSVM", random_seed = 1234, folds = 1) %>%
94-
set_mode("classification")
95-
96-
ctrl <- fit_control(verbosity = 0, catch = FALSE)
97-
98-
# ------------------------------------------------------------------------------
99-
100-
test_that('svm rbf regression', {
101-
102-
skip_if_not_installed("liquidSVM")
103-
104-
expect_warning(
105-
expect_error(
106-
fit_xy(
107-
reg_mod,
108-
control = ctrl,
109-
x = hpc[, 2:4],
110-
y = hpc$compounds
111-
),
112-
regexp = NA
113-
)
114-
)
115-
116-
expect_warning(
117-
expect_error(
118-
fit(
119-
reg_mod,
120-
compounds ~ .,
121-
data = hpc[, -5],
122-
control = ctrl
123-
),
124-
regexp = NA
125-
)
126-
)
127-
128-
})
129-
130-
131-
test_that('svm rbf regression prediction', {
132-
133-
skip_if_not_installed("liquidSVM")
134-
135-
expect_warning(
136-
reg_form <-
137-
fit(
138-
object = reg_mod,
139-
formula = compounds ~ .,
140-
data = hpc[, -5],
141-
control = ctrl
142-
)
143-
)
144-
145-
expect_warning(
146-
reg_xy_form <-
147-
fit_xy(
148-
object = reg_mod,
149-
x = hpc[, 2:4],
150-
y = hpc$compounds,
151-
control = ctrl
152-
)
153-
)
154-
expect_equal(reg_form$spec, reg_xy_form$spec)
155-
156-
expect_warning(
157-
liquidSVM_form <-
158-
liquidSVM::svm(
159-
x = compounds ~ .,
160-
y = hpc[, -5],
161-
gammas = .1,
162-
lambdas = 0.25,
163-
folds = 1,
164-
random_seed = 1234
165-
)
166-
)
167-
168-
expect_warning(
169-
liquidSVM_xy_form <-
170-
liquidSVM::svm(
171-
x = hpc[, 2:4],
172-
y = hpc$compounds,
173-
gammas = .1,
174-
lambdas = 0.25,
175-
folds = 1,
176-
random_seed = 1234
177-
)
178-
)
179-
180-
# check coeffs for liquidSVM formula and liquidSVM xy fit interfaces
181-
expect_equal(liquidSVM::getSolution(liquidSVM_form)[c("coeff", "sv")],
182-
liquidSVM::getSolution(liquidSVM_xy_form)[c("coeff", "sv")])
183-
184-
# check predictions for liquidSVM formula and liquidSVM xy interfaces
185-
liquidSVM_form_preds <- predict(liquidSVM_form, hpc[1:3, 2:4])
186-
liquidSVM_form_xy_preds <- predict(liquidSVM_xy_form, hpc[1:3, 2:4])
187-
expect_equal(liquidSVM_form_preds, liquidSVM_form_xy_preds)
188-
189-
# check predictions for parsnip formula and liquidSVM formula interfaces
190-
liquidSVM_pred <-
191-
structure(
192-
list(.pred = liquidSVM_form_preds),
193-
row.names = c(NA, -3L), class = c("tbl_df", "tbl", "data.frame"))
194-
195-
parsnip_pred <- predict(reg_form, hpc[1:3, 2:4])
196-
expect_equal(as.data.frame(liquidSVM_pred), as.data.frame(parsnip_pred))
197-
198-
# check that coeffs are equal for formula methods called via parsnip and liquidSVM
199-
expect_equal(liquidSVM::getSolution(reg_form$fit)[c("coeff", "sv")],
200-
liquidSVM::getSolution(liquidSVM_form)[c("coeff", "sv")])
201-
202-
# check coeffs are equivalent for parsnip fit_xy and parsnip formula methods
203-
expect_equal(liquidSVM::getSolution(reg_form$fit)[c("coeff", "sv")],
204-
liquidSVM::getSolution(reg_xy_form$fit)[c("coeff", "sv")])
205-
206-
# check predictions are equal for parsnip xy and liquidSVM xy methods
207-
parsnip_xy_pred <- predict(reg_xy_form, hpc[1:3, -c(1, 5)])
208-
expect_equal(as.data.frame(liquidSVM_pred), as.data.frame(parsnip_xy_pred))
209-
})
210-

0 commit comments

Comments
 (0)