Skip to content

Commit d6b345c

Browse files
committed
add plotting tests for randomForest
1 parent e389e08 commit d6b345c

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

tests/testthat/test_randomForest.R

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,35 @@ test_that("min_depth_interactions works", {
3939
0)
4040
})
4141

42+
test_that("plot_multi_way_importance works", {
43+
p <- plot_multi_way_importance(rf_c)
44+
expect_silent(print(p))
45+
})
46+
47+
test_that("plot_min_depth_distribution works", {
48+
p <- plot_min_depth_distribution(rf_c)
49+
expect_silent(print(p))
50+
})
51+
52+
test_that("plot_min_depth_interactions works", {
53+
p <- plot_min_depth_interactions(rf_c)
54+
expect_silent(print(p))
55+
})
56+
57+
test_that("plot_predict_interaction works", {
58+
p <- plot_predict_interaction(rf_c, data = iris, variable1 = "Petal.Width", variable2 = "Petal.Length")
59+
expect_silent(print(p))
60+
})
61+
62+
test_that("plot_importance_ggpairs works", {
63+
p <- plot_importance_ggpairs(rf_c)
64+
expect_silent(suppressMessages(print(p)))
65+
})
66+
67+
test_that("plot_importance_rankings works", {
68+
p <- plot_importance_rankings(rf_c)
69+
expect_silent(suppressWarnings(suppressMessages(print(p))))
70+
})
4271

4372
context("Test randomForest regression forests")
4473

@@ -69,6 +98,35 @@ test_that("min_depth_interactions works", {
6998
1)
7099
})
71100

101+
test_that("plot_multi_way_importance works", {
102+
p <- plot_multi_way_importance(rf_r)
103+
expect_silent(suppressWarnings(print(p)))
104+
})
105+
106+
test_that("plot_min_depth_distribution works", {
107+
p <- plot_min_depth_distribution(rf_r)
108+
expect_silent(print(p))
109+
})
110+
111+
test_that("plot_min_depth_interactions works", {
112+
p <- plot_min_depth_interactions(rf_r)
113+
expect_silent(print(p))
114+
})
115+
116+
test_that("plot_predict_interaction works", {
117+
p <- plot_predict_interaction(rf_r, data = mtcars, variable1 = "cyl", variable2 = "wt")
118+
expect_silent(print(p))
119+
})
120+
121+
test_that("plot_importance_ggpairs works", {
122+
p <- plot_importance_ggpairs(rf_r)
123+
expect_silent(suppressWarnings(suppressMessages(print(p))))
124+
})
125+
126+
test_that("plot_importance_rankings works", {
127+
p <- plot_importance_rankings(rf_r)
128+
expect_silent(suppressWarnings(suppressMessages(print(p))))
129+
})
72130

73131
context("Test randomForest unsupervised forests")
74132

@@ -98,3 +156,33 @@ test_that("min_depth_interactions works", {
98156
expect_equivalent(min_depth_int[min_depth_int$interaction == "Petal.Width:Sepal.Length", ]$mean_min_depth,
99157
1)
100158
})
159+
160+
test_that("plot_multi_way_importance works", {
161+
p <- plot_multi_way_importance(rf_u)
162+
expect_silent(suppressWarnings(print(p)))
163+
})
164+
165+
test_that("plot_min_depth_distribution works", {
166+
p <- plot_min_depth_distribution(rf_u)
167+
expect_silent(print(p))
168+
})
169+
170+
test_that("plot_min_depth_interactions works", {
171+
p <- plot_min_depth_interactions(rf_u)
172+
expect_silent(print(p))
173+
})
174+
175+
test_that("plot_predict_interaction does not work for unsupervised forests", {
176+
expect_warning(p <- plot_predict_interaction(rf_u, data = iris, variable1 = "Petal.Width", variable2 = "Sepal.Length"))
177+
expect_null(p)
178+
})
179+
180+
test_that("plot_importance_ggpairs works", {
181+
p <- plot_importance_ggpairs(rf_u)
182+
expect_silent(suppressWarnings(suppressMessages(print(p))))
183+
})
184+
185+
test_that("plot_importance_rankings works", {
186+
p <- plot_importance_rankings(rf_u)
187+
expect_silent(suppressWarnings(suppressMessages(print(p))))
188+
})

0 commit comments

Comments
 (0)