Skip to content

Commit 6951d1c

Browse files
committed
Re-add all tests
1 parent fd3e51f commit 6951d1c

File tree

1 file changed

+102
-102
lines changed

1 file changed

+102
-102
lines changed

tests/testthat/test-lightgbm.R

Lines changed: 102 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -15,105 +15,105 @@ test_that("simple test", {
1515
expect_s3_class(model, "lgb.CVBooster")
1616
})
1717

18-
# test_that("lightgbm", {
19-
#
20-
# model <- parsnip::boost_tree(mtry = 1, trees = 50, tree_depth = 15, min_n = 1)
21-
#
22-
# expect_all_modes_works(model, 'lightgbm')
23-
# })
24-
#
25-
#
26-
# test_that('lightgbm alternate objective', {
27-
# skip_if_not_installed("lightgbm")
28-
#
29-
# spec <- boost_tree(mtry = 1, trees = 50, tree_depth = 15, min_n = 1) %>%
30-
# set_engine("lightgbm", objective = "huber") %>%
31-
# set_mode("regression")
32-
#
33-
# lgb_fit <- spec %>% fit(mpg ~ ., data = mtcars)
34-
#
35-
# info <- jsonlite::fromJSON(lightgbm::lgb.dump(lgb_fit$fit))
36-
#
37-
# expect_equal(info$objective, "huber")
38-
# })
39-
#
40-
# test_that("lightgbm with tune", {
41-
#
42-
# model <- parsnip::boost_tree(
43-
# mtry = 5,
44-
# learn_rate = tune(),
45-
# loss_reduction = tune(),
46-
# sample_size = tune(),
47-
# trees = tune(),
48-
# min_n = tune(),
49-
# tree_depth = tune()
50-
# )
51-
# model <- parsnip::set_engine(model, "lightgbm")
52-
#
53-
# expect_can_tune_boost_tree(model)
54-
#
55-
# })
56-
#
57-
#
58-
# test_that("lightgbm mtry", {
59-
#
60-
# hyperparameters <- data.frame(mtry = c(1, 2, 6))
61-
# for(i in 1:nrow(hyperparameters)) {
62-
# model <- parsnip::boost_tree(mtry = hyperparameters$mtry[i], min_n = 1)
63-
# expect_all_modes_works(model, 'lightgbm')
64-
# }
65-
#
66-
# })
67-
#
68-
# test_that("lightgbm trees", {
69-
#
70-
# hyperparameters <- data.frame(trees = c(1, 20, 300))
71-
# for(i in 1:nrow(hyperparameters)) {
72-
# model <- parsnip::boost_tree(trees = hyperparameters$trees[i], min_n = 1)
73-
# expect_all_modes_works(model, 'lightgbm')
74-
# }
75-
#
76-
# })
77-
#
78-
#
79-
# test_that("lightgbm min_n hyperparameter", {
80-
#
81-
# hyperparameters <- data.frame(min_n = c(1, 10))
82-
# for(i in 1:nrow(hyperparameters)) {
83-
# model <- parsnip::boost_tree(min_n = hyperparameters$min_n[i])
84-
# expect_all_modes_works(model, 'lightgbm')
85-
# }
86-
#
87-
# })
88-
#
89-
# test_that("lightgbm tree_depth", {
90-
# hyperparameters <- data.frame(tree_depth = c(1, 16))
91-
# for(i in 1:nrow(hyperparameters)) {
92-
# model <- parsnip::boost_tree(tree_depth = hyperparameters$tree_depth[i], min_n = 1)
93-
# expect_all_modes_works(model, 'lightgbm')
94-
# }
95-
# })
96-
#
97-
# test_that("lightgbm loss_reduction", {
98-
# hyperparameters <- data.frame(loss_reduction = c(0, 0.2, 2))
99-
# for(i in 1:nrow(hyperparameters)) {
100-
# model <- parsnip::boost_tree(loss_reduction = hyperparameters$loss_reduction[i], min_n = 1)
101-
# expect_all_modes_works(model, 'lightgbm')
102-
# }
103-
# })
104-
#
105-
# test_that("lightgbm tree_depth", {
106-
# hyperparameters <- data.frame(loss_reduction = c(0, 0.2, 2))
107-
# for(i in 1:nrow(hyperparameters)) {
108-
# model <- parsnip::boost_tree(loss_reduction = hyperparameters$loss_reduction[i], min_n = 1)
109-
# expect_all_modes_works(model, 'lightgbm')
110-
# }
111-
# })
112-
#
113-
# test_that("lightgbm multi_predict", {
114-
# model <- parsnip::boost_tree(mtry = 5, trees = 5, mode = "regression", min_n = 1)
115-
# model <- parsnip::set_engine(model, "lightgbm")
116-
#
117-
# expect_multi_predict_works(model)
118-
# })
119-
#
18+
test_that("lightgbm", {
19+
20+
model <- parsnip::boost_tree(mtry = 1, trees = 50, tree_depth = 15, min_n = 1)
21+
22+
expect_all_modes_works(model, 'lightgbm')
23+
})
24+
25+
26+
test_that('lightgbm alternate objective', {
27+
skip_if_not_installed("lightgbm")
28+
29+
spec <- boost_tree(mtry = 1, trees = 50, tree_depth = 15, min_n = 1) %>%
30+
set_engine("lightgbm", objective = "huber") %>%
31+
set_mode("regression")
32+
33+
lgb_fit <- spec %>% fit(mpg ~ ., data = mtcars)
34+
35+
info <- jsonlite::fromJSON(lightgbm::lgb.dump(lgb_fit$fit))
36+
37+
expect_equal(info$objective, "huber")
38+
})
39+
40+
test_that("lightgbm with tune", {
41+
42+
model <- parsnip::boost_tree(
43+
mtry = 5,
44+
learn_rate = tune(),
45+
loss_reduction = tune(),
46+
sample_size = tune(),
47+
trees = tune(),
48+
min_n = tune(),
49+
tree_depth = tune()
50+
)
51+
model <- parsnip::set_engine(model, "lightgbm")
52+
53+
expect_can_tune_boost_tree(model)
54+
55+
})
56+
57+
58+
test_that("lightgbm mtry", {
59+
60+
hyperparameters <- data.frame(mtry = c(1, 2, 6))
61+
for(i in 1:nrow(hyperparameters)) {
62+
model <- parsnip::boost_tree(mtry = hyperparameters$mtry[i], min_n = 1)
63+
expect_all_modes_works(model, 'lightgbm')
64+
}
65+
66+
})
67+
68+
test_that("lightgbm trees", {
69+
70+
hyperparameters <- data.frame(trees = c(1, 20, 300))
71+
for(i in 1:nrow(hyperparameters)) {
72+
model <- parsnip::boost_tree(trees = hyperparameters$trees[i], min_n = 1)
73+
expect_all_modes_works(model, 'lightgbm')
74+
}
75+
76+
})
77+
78+
79+
test_that("lightgbm min_n hyperparameter", {
80+
81+
hyperparameters <- data.frame(min_n = c(1, 10))
82+
for(i in 1:nrow(hyperparameters)) {
83+
model <- parsnip::boost_tree(min_n = hyperparameters$min_n[i])
84+
expect_all_modes_works(model, 'lightgbm')
85+
}
86+
87+
})
88+
89+
test_that("lightgbm tree_depth", {
90+
hyperparameters <- data.frame(tree_depth = c(1, 16))
91+
for(i in 1:nrow(hyperparameters)) {
92+
model <- parsnip::boost_tree(tree_depth = hyperparameters$tree_depth[i], min_n = 1)
93+
expect_all_modes_works(model, 'lightgbm')
94+
}
95+
})
96+
97+
test_that("lightgbm loss_reduction", {
98+
hyperparameters <- data.frame(loss_reduction = c(0, 0.2, 2))
99+
for(i in 1:nrow(hyperparameters)) {
100+
model <- parsnip::boost_tree(loss_reduction = hyperparameters$loss_reduction[i], min_n = 1)
101+
expect_all_modes_works(model, 'lightgbm')
102+
}
103+
})
104+
105+
test_that("lightgbm tree_depth", {
106+
hyperparameters <- data.frame(loss_reduction = c(0, 0.2, 2))
107+
for(i in 1:nrow(hyperparameters)) {
108+
model <- parsnip::boost_tree(loss_reduction = hyperparameters$loss_reduction[i], min_n = 1)
109+
expect_all_modes_works(model, 'lightgbm')
110+
}
111+
})
112+
113+
test_that("lightgbm multi_predict", {
114+
model <- parsnip::boost_tree(mtry = 5, trees = 5, mode = "regression", min_n = 1)
115+
model <- parsnip::set_engine(model, "lightgbm")
116+
117+
expect_multi_predict_works(model)
118+
})
119+

0 commit comments

Comments
 (0)