Skip to content

liquidSVM changes #301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,5 @@ Suggests:
rpart,
MASS,
nlme,
modeldata
modeldata,
liquidSVM
10 changes: 9 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
# parsnip 0.1.1

## New Features

* `liquidSVM` was added as an engine for `svm_rbf()` (#300)

## Fixes

* The error message for missing packages was fixed (#289 and #292)


## Other Changes

* S3 dispatch for `tidy()` was broken on R 4.0.

* The error message for missing packages was fixed (#289 and #292)

# parsnip 0.0.5

Expand Down
5 changes: 0 additions & 5 deletions R/svm_rbf.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@
#' \item \pkg{R}: `"liquidSVM"`
#' }
#'
#' Note that models created using the `liquidSVM` engine cannot be saved like
#' conventional R objects. The `fit` slot of the `model_fit` object has to be
#' saved separately using the `liquidSVM::write.liquidSVM()` function. Likewise
#' to restore a model, the `fit` slot has to be replaced with the model that is
#' read using the `liquidSVM::read.liquidSVM()` function.
#'
#' @includeRmd man/rmd/svm-rbf.Rmd details
#'
Expand Down
9 changes: 6 additions & 3 deletions R/svm_rbf_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,12 @@ set_pred(
type = "prob",
value = list(
pre = function(x, object) {
if (object$fit$predict.prob == FALSE)
stop("`svm` model does not appear to use class probabilities. Was ",
"the model fit with `predict.prob = TRUE`?", call. = FALSE)
if (!object$fit$predict.prob) {
rlang::abort(
paste0("`svm` model does not appear to use class probabilities. Was ",
"the model fit with `predict.prob = TRUE`?")
)
}
x
},
post = function(result, object) {
Expand Down
26 changes: 26 additions & 0 deletions man/rmd/svm-rbf.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,32 @@ svm_rbf() %>%
translate()
```

## liquidSVM

```{r liquidSVM-reg}
svm_rbf() %>%
set_engine("liquidSVM") %>%
set_mode("regression") %>%
translate()
```

```{r liquidSVM-cls}
svm_rbf() %>%
set_engine("liquidSVM") %>%
set_mode("classification") %>%
translate()
```

Note that models created using the `liquidSVM` engine cannot be saved like
conventional R objects. The `fit` slot of the `model_fit` object has to be saved
separately using the `liquidSVM::write.liquidSVM()` function. Likewise to restore
a model, the `fit` slot has to be replaced with the model that is read using the
`liquidSVM::read.liquidSVM()` function.

`liquidSVM` parameterizes the kernel parameter differently than `kernlab`. To
translate between engines, `sigma = 1/gammas^2`. Users will be specifying
`sigma` and the function translates the value to `gamma`.

## Parameter translations

The standardized parameter names in parsnip can be mapped to their original
Expand Down
48 changes: 43 additions & 5 deletions man/svm_rbf.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.