Skip to content

Commit 7a3e280

Browse files
committed
Add tidy method for Liblinear parsnip models
1 parent d48be86 commit 7a3e280

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ S3method(req_pkgs,model_fit)
6666
S3method(req_pkgs,model_spec)
6767
S3method(required_pkgs,model_fit)
6868
S3method(required_pkgs,model_spec)
69+
S3method(tidy,"_LiblineaR")
6970
S3method(tidy,"_elnet")
7071
S3method(tidy,"_fishnet")
7172
S3method(tidy,"_lognet")

R/tidy_liblinear.R

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#' tidy methods for LiblineaR models
2+
#'
3+
#' `tidy()` methods for the various `LiblineaR` models that return the
4+
#' coefficients from the `parsnip` model fit.
5+
#' @param x A fitted `parsnip` model that used the `LiblineaR` engine.
6+
#' @param ... Not used
7+
#' @return A tibble with columns `term` and `estimate`.
8+
#' @keywords internal
9+
#' @export
10+
11+
tidy._LiblineaR <- function(x, ...) {
12+
check_installs(x$spec)
13+
ret <- tibble(colnames(x$fit$W), x$fit$W[1,])
14+
colnames(ret) <- c("term", "estimate")
15+
16+
ret
17+
}

man/tidy._LiblineaR.Rd

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

0 commit comments

Comments
 (0)