Skip to content

Commit

Permalink
rename objects in test xgboost
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilHvitfeldt committed Dec 17, 2024
1 parent 1a7f1e6 commit df167a6
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions tests/testthat/test-model-xgboost.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ test_that("boost_tree(), objective = binary:logistic, works with type = class",

mtcars$vs <- factor(mtcars$vs)

lr_spec <- parsnip::boost_tree(mode = "classification", engine = "xgboost")
bt_spec <- parsnip::boost_tree(mode = "classification", engine = "xgboost")

lr_fit <- parsnip::fit(lr_spec, vs ~ disp + mpg + hp, mtcars)
bt_fit <- parsnip::fit(bt_spec, vs ~ disp + mpg + hp, mtcars)

orb_obj <- orbital(lr_fit, type = "class")
orb_obj <- orbital(bt_fit, type = "class")

preds <- predict(orb_obj, mtcars)
exps <- predict(lr_fit, mtcars)
exps <- predict(bt_fit, mtcars)

expect_named(preds, ".pred_class")
expect_type(preds$.pred_class, "character")
Expand All @@ -28,14 +28,14 @@ test_that("boost_tree(), objective = binary:logistic, works with type = class",
skip_if_not_installed("tidypredict")
skip_if_not_installed("xgboost")

lr_spec <- parsnip::boost_tree(mode = "classification", engine = "xgboost")
bt_spec <- parsnip::boost_tree(mode = "classification", engine = "xgboost")

lr_fit <- parsnip::fit(lr_spec, Species ~ ., iris)
bt_fit <- parsnip::fit(bt_spec, Species ~ ., iris)

orb_obj <- orbital(lr_fit, type = "class")
orb_obj <- orbital(bt_fit, type = "class")

preds <- predict(orb_obj, iris)
exps <- predict(lr_fit, iris)
exps <- predict(bt_fit, iris)

expect_named(preds, ".pred_class")
expect_type(preds$.pred_class, "character")
Expand All @@ -53,14 +53,14 @@ test_that("boost_tree(), objective = binary:logistic, works with type = prob", {

mtcars$vs <- factor(mtcars$vs)

lr_spec <- parsnip::boost_tree(mode = "classification", engine = "xgboost")
bt_spec <- parsnip::boost_tree(mode = "classification", engine = "xgboost")

lr_fit <- parsnip::fit(lr_spec, vs ~ disp + mpg + hp, mtcars)
bt_fit <- parsnip::fit(bt_spec, vs ~ disp + mpg + hp, mtcars)

orb_obj <- orbital(lr_fit, type = "prob")
orb_obj <- orbital(bt_fit, type = "prob")

preds <- predict(orb_obj, mtcars)
exps <- predict(lr_fit, mtcars, type = "prob")
exps <- predict(bt_fit, mtcars, type = "prob")

expect_named(preds, c(".pred_0", ".pred_1"))
expect_type(preds$.pred_0, "double")
Expand All @@ -83,14 +83,14 @@ test_that("boost_tree(), objective = binary:logistic, works with type = prob", {
skip_if_not_installed("tidypredict")
skip_if_not_installed("xgboost")

lr_spec <- parsnip::boost_tree(mode = "classification", engine = "xgboost")
bt_spec <- parsnip::boost_tree(mode = "classification", engine = "xgboost")

lr_fit <- parsnip::fit(lr_spec, Species ~ ., iris)
bt_fit <- parsnip::fit(bt_spec, Species ~ ., iris)

orb_obj <- orbital(lr_fit, type = "prob")
orb_obj <- orbital(bt_fit, type = "prob")

preds <- predict(orb_obj, iris)
exps <- predict(lr_fit, iris, type = "prob")
exps <- predict(bt_fit, iris, type = "prob")

expect_named(preds, paste0(".pred_", levels(iris$Species)))
expect_type(preds$.pred_setosa, "double")
Expand All @@ -116,16 +116,16 @@ test_that("boost_tree(), objective = binary:logistic, works with type = c(class,

mtcars$vs <- factor(mtcars$vs)

lr_spec <- parsnip::boost_tree(mode = "classification", engine = "xgboost")
bt_spec <- parsnip::boost_tree(mode = "classification", engine = "xgboost")

lr_fit <- parsnip::fit(lr_spec, vs ~ disp + mpg + hp, mtcars)
bt_fit <- parsnip::fit(bt_spec, vs ~ disp + mpg + hp, mtcars)

orb_obj <- orbital(lr_fit, type = c("class", "prob"))
orb_obj <- orbital(bt_fit, type = c("class", "prob"))

preds <- predict(orb_obj, mtcars)
exps <- dplyr::bind_cols(
predict(lr_fit, mtcars, type = c("class")),
predict(lr_fit, mtcars, type = c("prob"))
predict(bt_fit, mtcars, type = c("class")),
predict(bt_fit, mtcars, type = c("prob"))
)

expect_named(preds, c(".pred_class", ".pred_0", ".pred_1"))
Expand All @@ -151,16 +151,16 @@ test_that("boost_tree(), objective = binary:logistic, works with type = c(class,
skip_if_not_installed("tidypredict")
skip_if_not_installed("xgboost")

lr_spec <- parsnip::boost_tree(mode = "classification", engine = "xgboost")
bt_spec <- parsnip::boost_tree(mode = "classification", engine = "xgboost")

lr_fit <- parsnip::fit(lr_spec, Species ~ ., iris)
bt_fit <- parsnip::fit(bt_spec, Species ~ ., iris)

orb_obj <- orbital(lr_fit, type = c("class", "prob"))
orb_obj <- orbital(bt_fit, type = c("class", "prob"))

preds <- predict(orb_obj, iris)
exps <- dplyr::bind_cols(
predict(lr_fit, iris, type = c("class")),
predict(lr_fit, iris, type = c("prob"))
predict(bt_fit, iris, type = c("class")),
predict(bt_fit, iris, type = c("prob"))
)

expect_named(preds, c(".pred_class", paste0(".pred_", levels(iris$Species))))
Expand Down

0 comments on commit df167a6

Please sign in to comment.