koalaverse / vip
Showing 3 of 137 files from the diff.
Other files ignored by Codecov
man/vi_model.Rd has changed.
docs/link.svg was deleted.
NAMESPACE has changed.
docs/index.html was deleted.
docs/pkgdown.css was deleted.
docs/pkgdown.yml was deleted.
.Rbuildignore has changed.
docs/docsearch.js was deleted.
man/vi.Rd has changed.
docs/404.html was deleted.
docs/authors.html was deleted.
docs/pkgdown.js was deleted.
NEWS.md has changed.
DESCRIPTION has changed.

@@ -179,32 +179,3 @@
Loading
179 179
  tib
180 180
181 181
}
182 -
183 -
184 -
#' @rdname vi
185 -
#'
186 -
#' @export
187 -
vi.model_fit <- function(object, ...) {  # package: parsnip
188 -
  vi(object$fit, ...)
189 -
}
190 -
191 -
192 -
#' @rdname vi
193 -
#'
194 -
#' @export
195 -
vi.WrappedModel <- function(object, ...) {  # package: mlr
196 -
  vi(object$learner.model, ...)
197 -
}
198 -
199 -
200 -
#' @rdname vi
201 -
#'
202 -
#' @export
203 -
vi.Learner <- function(object, ...) {  # package: mlr3
204 -
  if (is.null(object$model)) {
205 -
    stop("No fitted model found. Did you forget to call ",
206 -
         deparse(substitute(object)), "$train()?",
207 -
         call. = FALSE)
208 -
  }
209 -
  vi(object$model, ...)
210 -
}

@@ -8,19 +8,6 @@
Loading
8 8
magrittr::`%>%`
9 9
10 10
11 -
#' Arrange multiple grobs on a page
12 -
#'
13 -
#' See \code{\link[gridExtra:arrangeGrob]{grid.arrange}} for more details.
14 -
#'
15 -
#' @name grid.arrange
16 -
#' @rdname grid.arrange
17 -
#' @keywords internal
18 -
#' @export
19 -
#' @importFrom gridExtra grid.arrange
20 -
#' @usage grid.arrange(..., newpage = TRUE)
21 -
NULL
22 -
23 -
24 11
#' @keywords internal
25 12
abbreviate_names <- function(x, minlength) {
26 13
  x$Variable <- abbreviate(x$Variable, minlength = minlength)

@@ -14,6 +14,10 @@
Loading
14 14
#' argument in \code{\link[glmnet:predict.glmnet]{coef.glmnet}}). See the section on
15 15
#' \code{\link[glmnet]{glmnet}} in the details below.
16 16
#'
17 +
#' @param ncomp An integer for the number of partial least squares components
18 +
#' to be used in the importance calculations. If more components are requested
19 +
#' than were used in the model, all of the model's components are used.
20 +
#'
17 21
#' @param ... Additional optional arguments to be passed on to other methods.
18 22
#'
19 23
#' @return A tidy data frame (i.e., a \code{"tibble"} object) with two columns:
@@ -610,12 +614,64 @@
Loading
610 614
}
611 615
612 616
617 +
# Package: mixOmics  -----------------------------------------------------------
618 +
619 +
#' @rdname vi_model
620 +
#'
621 +
#' @export
622 +
vi_model.mixo_pls <- function(object, ncomp = NULL, ...) {
623 +
624 +
  # Check for dependency
625 +
  if (!requireNamespace("mixOmics", quietly = TRUE)) {
626 +
    stop("Bioconductor package \"mixOmics\" needed for this function to work. ",
627 +
         "Please install it.", call. = FALSE)
628 +
  }
629 +
  if (is.null(ncomp)) {
630 +
    ncomp <- object$ncomp
631 +
  } else {
632 +
    if (length(ncomp) != 1) {
633 +
      stop("'ncomp' should be a single integer.")
634 +
    }
635 +
    if (!is.integer(ncomp)) {
636 +
      ncomp <- as.integer(ncomp)
637 +
    }
638 +
  }
639 +
640 +
  vis <- mixOmics::vip(object)
641 +
  if (ncomp > ncol(vis)) {
642 +
    warning(ncomp, " components were requested but only ", ncol(vis),
643 +
            " are available. Results are for ", ncol(vis), ".")
644 +
    ncomp <- ncol(vis)
645 +
  }
646 +
647 +
  tib <- tibble::tibble(
648 +
    "Variable" = rownames(vis),
649 +
    "Importance" = vis[,ncomp]
650 +
  )
651 +
652 +
  # Add variable importance type attribute
653 +
  attr(tib, which = "type") <- "mixOmics"
654 +
655 +
  # Add "vi" class
656 +
  class(tib) <- c("vi", class(tib))
657 +
658 +
  # Return results
659 +
  tib
660 +
661 +
}
662 +
663 +
#' @rdname vi_model
664 +
#'
665 +
#' @export
666 +
vi_model.mixo_spls <- vi_model.mixo_pls
667 +
668 +
613 669
# Package: mlr -----------------------------------------------------------------
614 670
615 671
#' @rdname vi_model
616 672
#'
617 673
#' @export
618 -
vi_model.WrappedModel <- function(object, ...) {  # package: mlr
674 +
vi_model.WrappedModel <- function(object, ...) {
619 675
  vi_model(object$learner.model, ...)
620 676
}
621 677
@@ -625,7 +681,7 @@
Loading
625 681
#' @rdname vi_model
626 682
#'
627 683
#' @export
628 -
vi_model.Learner <- function(object, ...) {  # package: mlr3
684 +
vi_model.Learner <- function(object, ...) {
629 685
  if (is.null(object$model)) {
630 686
    stop("No fitted model found. Did you forget to call ",
631 687
         deparse(substitute(object)), "$train()?",
@@ -721,16 +777,6 @@
Loading
721 777
}
722 778
723 779
724 -
# Package: parsnip -------------------------------------------------------------
725 -
726 -
#' @rdname vi_model
727 -
#'
728 -
#' @export
729 -
vi_model.model_fit <- function(object, ...) {  # package: parsnip
730 -
  vi_model(object$fit, ...)
731 -
}
732 -
733 -
734 780
# Package: party ---------------------------------------------------------------
735 781
736 782
#' @rdname vi_model
@@ -1302,6 +1348,28 @@
Loading
1302 1348
}
1303 1349
1304 1350
1351 +
# Package: tidymodels ==========================================================
1352 +
1353 +
# Package: parsnip -------------------------------------------------------------
1354 +
1355 +
#' @rdname vi_model
1356 +
#'
1357 +
#' @export
1358 +
vi_model.model_fit <- function(object, ...) {
1359 +
  vi(parsnip::extract_fit_engine(object), ...)
1360 +
}
1361 +
1362 +
# Package: workflows -----------------------------------------------------------
1363 +
1364 +
#' @rdname vi_model
1365 +
#'
1366 +
#' @export
1367 +
vi_model.workflow <- function(object, ...) {
1368 +
  vi(workflows::extract_fit_engine(object), ...)
1369 +
}
1370 +
1371 +
#===============================================================================
1372 +
1305 1373
# Package: xgboost -------------------------------------------------------------
1306 1374
1307 1375
#' @rdname vi_model
Files Coverage
R 63.64%
Project Totals (13 files) 63.64%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading