Skip to content

Commit 35ec46e

Browse files
committed
fix remaining test failures
Some more manual data entry and # classes in outcome variable issues.
1 parent a466fc4 commit 35ec46e

File tree

4 files changed

+21
-17
lines changed

4 files changed

+21
-17
lines changed

tests/testthat/test_boost_tree_xgboost.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ test_that('xgboost classification prediction', {
6565
)
6666

6767
xy_pred <- predict(xy_fit$fit, newdata = xgb.DMatrix(data = as.matrix(hpc[1:8, num_pred])), type = "class")
68-
xy_pred <- matrix(xy_pred, ncol = 3, byrow = TRUE)
68+
xy_pred <- matrix(xy_pred, ncol = 4, byrow = TRUE)
6969
xy_pred <- factor(levels(hpc$class)[apply(xy_pred, 1, which.max)], levels = levels(hpc$class))
7070
expect_equal(xy_pred, predict(xy_fit, new_data = hpc[1:8, num_pred], type = "class")$.pred_class)
7171

@@ -77,7 +77,7 @@ test_that('xgboost classification prediction', {
7777
)
7878

7979
form_pred <- predict(form_fit$fit, newdata = xgb.DMatrix(data = as.matrix(hpc[1:8, num_pred])), type = "class")
80-
form_pred <- matrix(form_pred, ncol = 3, byrow = TRUE)
80+
form_pred <- matrix(form_pred, ncol = 4, byrow = TRUE)
8181
form_pred <- factor(levels(hpc$class)[apply(form_pred, 1, which.max)], levels = levels(hpc$class))
8282
expect_equal(form_pred, predict(form_fit, new_data = hpc[1:8, num_pred], type = "class")$.pred_class)
8383
})

tests/testthat/test_mars.R

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,17 +188,21 @@ test_that('mars execution', {
188188
test_that('mars prediction', {
189189
skip_if_not_installed("earth")
190190

191-
uni_pred <- c(5.02371514510488, 4.70502120747471, 4.78973285129011, 4.81152592623742,
192-
5.08745393263092)
193-
inl_pred <- c(5.07584328502019, 4.64927636051174, 4.82786784324037, 4.74001260567429,
194-
5.15379794835255)
191+
uni_pred <- c(30.1466666666667, 30.1466666666667, 30.1466666666667,
192+
30.1466666666667, 30.1466666666667)
193+
inl_pred <- c(538.268789262046, 141.024903718634, 141.024903718634,
194+
141.024903718634, 141.024903718634)
195195
mv_pred <-
196196
structure(
197-
list(Sepal.Width =
198-
c(3.4874092243636, 3.34173526636919, 3.17647644756747, 3.14280919018489, 3.41457224536639),
199-
Petal.Width =
200-
c(0.237414046784062, 0.221455118452782, 0.18348960240454, 0.219523313672823, 0.229434582618422
201-
)), class = "data.frame", row.names = c(NA, -5L))
197+
list(compounds =
198+
c(371.334864384913, 129.475162245595, 256.094366313268,
199+
129.475162245595, 129.475162245595),
200+
input_fields =
201+
c(430.476046435458, 158.833790342308, 218.07635084308,
202+
158.833790342308, 158.833790342308)
203+
),
204+
class = "data.frame", row.names = c(NA, -5L)
205+
)
202206

203207
res_xy <- fit_xy(
204208
hpc_basic,

tests/testthat/test_predict_formats.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ context("check predict output structures")
1313
lm_fit <-
1414
linear_reg(mode = "regression") %>%
1515
set_engine("lm") %>%
16-
fit(class ~ ., data = hpc)
16+
fit(compounds ~ ., data = hpc)
1717

1818
class_dat <- airquality[complete.cases(airquality),]
1919
class_dat$Ozone <- factor(ifelse(class_dat$Ozone >= 31, "high", "low"))

tests/testthat/test_rand_forest_ranger.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,11 @@ test_that('additional descriptor tests', {
310310

311311
##
312312

313-
exp_wts <- quo(c(min(.lvls()), 20, 10))
313+
exp_wts <- quo(c(min(.lvls()), 20, 10, 1))
314314

315315
descr_other_xy <- fit_xy(
316316
rand_forest(mode = "classification", mtry = 2) %>%
317-
set_engine("ranger", class.weights = c(min(.lvls()), 20, 10)),
317+
set_engine("ranger", class.weights = c(min(.lvls()), 20, 10, 1)),
318318
x = hpc[, 1:4],
319319
y = hpc$class,
320320
control = ctrl
@@ -324,7 +324,7 @@ test_that('additional descriptor tests', {
324324

325325
descr_other_f <- fit(
326326
rand_forest(mode = "classification", mtry = 2) %>%
327-
set_engine("ranger", class.weights = c(min(.lvls()), 20, 10)),
327+
set_engine("ranger", class.weights = c(min(.lvls()), 20, 10, 1)),
328328
class ~ ., data = hpc,
329329
control = ctrl
330330
)
@@ -333,7 +333,7 @@ test_that('additional descriptor tests', {
333333

334334
descr_other_xy <- fit_xy(
335335
rand_forest(mode = "classification", mtry = 2) %>%
336-
set_engine("ranger", class.weights = c(min(.lvls()), 20, 10)),
336+
set_engine("ranger", class.weights = c(min(.lvls()), 20, 10, 1)),
337337
x = hpc[, 1:4],
338338
y = hpc$class,
339339
control = ctrl
@@ -343,7 +343,7 @@ test_that('additional descriptor tests', {
343343

344344
descr_other_f <- fit(
345345
rand_forest(mode = "classification", mtry = 2) %>%
346-
set_engine("ranger", class.weights = c(min(.lvls()), 20, 10)),
346+
set_engine("ranger", class.weights = c(min(.lvls()), 20, 10, 1)),
347347
class ~ ., data = hpc,
348348
control = ctrl
349349
)

0 commit comments

Comments
 (0)