|
| 1 | +# xgboost execution, classification |
| 2 | + |
| 3 | + Code |
| 4 | + res <- parsnip::fit(hpc_xgboost, class ~ novar, data = hpc, control = ctrl) |
| 5 | + Condition |
| 6 | + Error: |
| 7 | + ! object 'novar' not found |
| 8 | + |
| 9 | +# xgboost execution, regression |
| 10 | + |
| 11 | + Code |
| 12 | + res <- parsnip::fit_xy(car_basic, x = mtcars[, num_pred], y = factor(mtcars$vs), |
| 13 | + control = ctrl) |
| 14 | + Condition |
| 15 | + Error in `check_outcome()`: |
| 16 | + ! For a regression model, the outcome should be `numeric`, not a `factor`. |
| 17 | + |
1 | 18 | # submodel prediction |
2 | 19 |
|
3 | 20 | Code |
|
6 | 23 | Error in `multi_predict()`: |
7 | 24 | ! Please use `new_data` instead of `newdata`. |
8 | 25 |
|
| 26 | +# validation sets |
| 27 | + |
| 28 | + Code |
| 29 | + reg_fit <- boost_tree(trees = 20, mode = "regression") %>% set_engine("xgboost", |
| 30 | + validation = 3) %>% fit(mpg ~ ., data = mtcars[-(1:4), ]) |
| 31 | + Condition |
| 32 | + Error in `parsnip::xgb_train()`: |
| 33 | + ! `validation` should be on [0, 1). |
| 34 | + |
| 35 | +# early stopping |
| 36 | + |
| 37 | + Code |
| 38 | + reg_fit <- boost_tree(trees = 20, stop_iter = 30, mode = "regression") %>% |
| 39 | + set_engine("xgboost", validation = 0.1) %>% fit(mpg ~ ., data = mtcars[-(1:4), |
| 40 | + ]) |
| 41 | + Condition |
| 42 | + Warning: |
| 43 | + `early_stop` was reduced to 19. |
| 44 | + |
| 45 | +--- |
| 46 | + |
| 47 | + Code |
| 48 | + reg_fit <- boost_tree(trees = 20, stop_iter = 0, mode = "regression") %>% |
| 49 | + set_engine("xgboost", validation = 0.1) %>% fit(mpg ~ ., data = mtcars[-(1:4), |
| 50 | + ]) |
| 51 | + Condition |
| 52 | + Error in `parsnip::xgb_train()`: |
| 53 | + ! `early_stop` should be on [2, 20). |
| 54 | + |
9 | 55 | # xgboost data conversion |
10 | 56 |
|
11 | 57 | Code |
|
14 | 60 | Warning: |
15 | 61 | `event_level` can only be set for binary outcomes. |
16 | 62 |
|
| 63 | +# argument checks for data dimensions |
| 64 | + |
| 65 | + Code |
| 66 | + f_fit <- spec %>% fit(species ~ ., data = penguins, control = ctrl) |
| 67 | + Condition |
| 68 | + Warning: |
| 69 | + ! 1000 samples were requested but there were 333 rows in the data. |
| 70 | + i 333 will be used. |
| 71 | + |
| 72 | +--- |
| 73 | + |
| 74 | + Code |
| 75 | + xy_fit <- spec %>% fit_xy(x = penguins_dummy, y = penguins$species, control = ctrl) |
| 76 | + Condition |
| 77 | + Warning: |
| 78 | + ! 1000 samples were requested but there were 333 rows in the data. |
| 79 | + i 333 will be used. |
| 80 | + |
| 81 | +# count/proportion parameters |
| 82 | + |
| 83 | + Code |
| 84 | + boost_tree(mtry = 0.9, trees = 4) %>% set_engine("xgboost") %>% set_mode( |
| 85 | + "regression") %>% fit(mpg ~ ., data = mtcars) |
| 86 | + Condition |
| 87 | + Error in `recalc_param()`: |
| 88 | + ! The option `counts = TRUE` was used but `colsample_bynode` was given as 0.9. |
| 89 | + i Please use a value >= 1 or use `counts = FALSE`. |
| 90 | + |
17 | 91 | # interface to param arguments |
18 | 92 |
|
19 | 93 | ! Please supply elements of the `params` list argument as main arguments to `set_engine()` rather than as part of `params`. |
|
0 commit comments