Skip to content

Commit

Permalink
tests and docs for v1.5.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Staniak committed Sep 24, 2018
1 parent a18cfbd commit e919deb
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 4 deletions.
6 changes: 3 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# live 1.5.8

* Allow setting seed before sampling in `sample_locally2` to make results reproducible.
* Add new explainer: `local_permutation_importance` function.d
* Fixed problems with mlr dependency
* Add shortcut function for DALEX explainers
* Add new explainer: `local_permutation_importance` function.
* Fixed problems with mlr dependency.
* Add shortcut function for DALEX explainers: `local_approximation`.

# live 1.5.7

Expand Down
12 changes: 12 additions & 0 deletions R/dalex_shortcut.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,20 @@
#' @param kernel_type Function which will be used to calculate distances from
#' simulated observation to explained instance
#' @param ... Arguments to be passed to sample_locally2 function
#'
#' @return object of class live_explainer. More details in fit_explanation2 function help.
#'
#' @export
#'
#' @examples
#' \dontrun{
#' data('wine')
#' library(randomForest)
#' library(DALEX)
#' rf <- randomForest(quality~., data = wine)
#' expl <- explain(rf, wine, wine$quality)
#' live_expl <- local_approximation(expl, wine[5, ], "quality", 500)
#' }
#'

local_approximation <- function(explainer, observation, target_variable_name,
Expand Down
14 changes: 14 additions & 0 deletions man/local_approximation.Rd

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

3 changes: 2 additions & 1 deletion tests/testthat.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
library(testthat)
library(live)
library(mlr)
library(data.table)
library(lubridate)
library(DALEX)
library(data.table)

set.seed(1)
X <- as.data.frame(matrix(runif(5500), ncol = 11, nrow = 500))
Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/test_shortcut.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
context("Test shortcut for DALEX explainers")

mlm <- lm(quality ~., data = live::wine)
expl <- DALEX::explain(mlm, live::wine, live::wine$quality)

testthat::test_that("DALEX integration is okay", {
testthat::expect_is(
local_approximation(expl, live::wine[5, ], "quality", 500),
"live_explainer"
)
})

0 comments on commit e919deb

Please sign in to comment.