Skip to content

Commit

Permalink
safeguard tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hbaniecki committed Sep 3, 2019
1 parent 24a5955 commit 20add80
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
3 changes: 2 additions & 1 deletion tests/testthat/test_modelStudio.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
context("Check modelStudio() function")
library(DALEX)
source("test_objects.R")

ms1 <- modelStudio(explain_glm,
Expand Down Expand Up @@ -125,5 +126,5 @@ test_that("parallel", {
})

test_that("parallel rf", {
expect_is(ms_parallel, "r2d3")
expect_is(ms_parallel_rf, "r2d3")
})
1 change: 1 addition & 0 deletions tests/testthat/test_modelStudioOptions.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
context("Check options parameter and modelStudioOptions() function")
library(DALEX)
source("test_objects.R")

op <- modelStudioOptions()
Expand Down
14 changes: 7 additions & 7 deletions tests/testthat/test_objects.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ titanic_small <- titanic[sample(1:nrow(titanic), 500), c(1,2,3,6,7,9)]
model_titanic_glm <- glm(survived == "yes" ~ gender + age + fare + class + sibsp,
data = titanic_small, family = "binomial")

explain_titanic_glm <- explain(model_titanic_glm,
explain_titanic_glm <- DALEX::explain(model_titanic_glm,
data = titanic_small[,-6],
y = titanic_small$survived == "yes",
label = "glm", verbose = TRUE)
Expand All @@ -29,7 +29,7 @@ titanic_test <- titanic[sample(1:nrow(titanic), 500),]
model_glm <- glm(survived == "yes" ~.,
data = titanic_test, family = "binomial")

explain_glm <- explain(model_glm,
explain_glm <- DALEX::explain(model_glm,
data = titanic_test[,-9],
y = titanic_test$survived == "yes",
label = "glm", verbose = TRUE)
Expand All @@ -38,23 +38,23 @@ glm_numerical <- glm(survived == "yes" ~ age + fare + sibsp + parch,
data = titanic_test[, c(2,6,7,8,9)],
family = "binomial")

explain_glm_numerical <- explain(glm_numerical,
explain_glm_numerical <- DALEX::explain(glm_numerical,
data = titanic_test[, c(2,6,7,8)],
y = titanic_test$survived == "yes", verbose = TRUE)

glm_not_numerical <- glm(survived == "yes" ~ gender + class + embarked + country,
data = titanic_test[, c(1,3,4,5,9)],
family = "binomial")

explain_glm_not_numerical <- explain(glm_not_numerical,
explain_glm_not_numerical <- DALEX::explain(glm_not_numerical,
data = titanic_test[, c(1,3,4,5)],
y = titanic_test$survived == "yes", verbose = TRUE)

model_small <- glm(survived == "yes" ~ age + gender,
data = titanic_test[, c(1,2,9)],
family = "binomial")

explain_model_small <- explain(model_small,
explain_model_small <- DALEX::explain(model_small,
data = titanic_test[, c(1,2)],
y = titanic_test$survived == "yes", verbose = TRUE)

Expand All @@ -64,7 +64,7 @@ explain_model_small <- explain(model_small,
library("randomForest")

model_rf <- randomForest(m2.price ~. , data = apartments)
explain_rf <- explain(model_rf,
explain_rf <- DALEX::explain(model_rf,
data = apartments,
y = apartments$m2.price, verbose = TRUE)

Expand Down Expand Up @@ -103,7 +103,7 @@ model_artifficial <- glm(y ~.,
data = artifficial,
family = "binomial")

explain_artifficial <- explain(model_artifficial,
explain_artifficial <- DALEX::explain(model_artifficial,
data = artifficial[,-12],
y = artifficial[,12], verbose = TRUE)

0 comments on commit 20add80

Please sign in to comment.