Skip to content

Commit

Permalink
remove bundle reference for lightgbm (#1133)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpcouch authored Jul 22, 2024
1 parent 3967e5e commit 017b671
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 35 deletions.
25 changes: 10 additions & 15 deletions man/details_boost_tree_lightgbm.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions man/rmd/boost_tree_lightgbm.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ Non-numeric predictors (i.e., factors) are internally converted to numeric. In t
```{r child = "template-mtry-prop.Rmd"}
```

### Saving fitted model objects

```{r child = "template-bundle.Rmd"}
```

### Bagging

The `sample_size` argument is translated to the `bagging_fraction` parameter in the `param` argument of `lgb.train`. The argument is interpreted by lightgbm as a _proportion_ rather than a count, so bonsai internally reparameterizes the `sample_size` argument with [dials::sample_prop()] during tuning.
Expand Down
27 changes: 12 additions & 15 deletions man/rmd/boost_tree_lightgbm.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Note that parsnip's translation can be overridden via the `counts` argument, sup
The **bonsai** extension package is required to fit this model.


```r
``` r
boost_tree(
mtry = integer(), trees = integer(), tree_depth = integer(),
learn_rate = numeric(), min_n = integer(), loss_reduction = numeric()
Expand All @@ -57,18 +57,19 @@ boost_tree(
##
## Model fit template:
## bonsai::train_lightgbm(x = missing_arg(), y = missing_arg(),
## feature_fraction_bynode = integer(), num_iterations = integer(),
## min_data_in_leaf = integer(), max_depth = integer(), learning_rate = numeric(),
## min_gain_to_split = numeric(), verbose = -1, num_threads = 0,
## seed = sample.int(10^5, 1), deterministic = TRUE)
## weights = missing_arg(), feature_fraction_bynode = integer(),
## num_iterations = integer(), min_data_in_leaf = integer(),
## max_depth = integer(), learning_rate = numeric(), min_gain_to_split = numeric(),
## verbose = -1, num_threads = 0, seed = sample.int(10^5, 1),
## deterministic = TRUE)
```

## Translation from parsnip to the original package (classification)

The **bonsai** extension package is required to fit this model.


```r
``` r
boost_tree(
mtry = integer(), trees = integer(), tree_depth = integer(),
learn_rate = numeric(), min_n = integer(), loss_reduction = numeric()
Expand All @@ -93,10 +94,11 @@ boost_tree(
##
## Model fit template:
## bonsai::train_lightgbm(x = missing_arg(), y = missing_arg(),
## feature_fraction_bynode = integer(), num_iterations = integer(),
## min_data_in_leaf = integer(), max_depth = integer(), learning_rate = numeric(),
## min_gain_to_split = numeric(), verbose = -1, num_threads = 0,
## seed = sample.int(10^5, 1), deterministic = TRUE)
## weights = missing_arg(), feature_fraction_bynode = integer(),
## num_iterations = integer(), min_data_in_leaf = integer(),
## max_depth = integer(), learning_rate = numeric(), min_gain_to_split = numeric(),
## verbose = -1, num_threads = 0, seed = sample.int(10^5, 1),
## deterministic = TRUE)
```

[bonsai::train_lightgbm()] is a wrapper around [lightgbm::lgb.train()] (and other functions) that make it easier to run this model.
Expand All @@ -121,11 +123,6 @@ parsnip and its extensions accommodate this parameterization using the `counts`

`mtry` is a main model argument for \\code{\\link[=boost_tree]{boost_tree()}} and \\code{\\link[=rand_forest]{rand_forest()}}, and thus should not have an engine-specific interface. So, regardless of engine, `counts` defaults to `TRUE`. For engines that support the proportion interpretation (currently `"xgboost"` and `"xrf"`, via the rules package, and `"lightgbm"` via the bonsai package) the user can pass the `counts = FALSE` argument to `set_engine()` to supply `mtry` values within `[0, 1]`.

### Saving fitted model objects


Models fitted with this engine may require native serialization methods to be properly saved and/or passed between R sessions. To learn more about preparing fitted models for serialization, see the bundle package.

### Bagging

The `sample_size` argument is translated to the `bagging_fraction` parameter in the `param` argument of `lgb.train`. The argument is interpreted by lightgbm as a _proportion_ rather than a count, so bonsai internally reparameterizes the `sample_size` argument with [dials::sample_prop()] during tuning.
Expand Down

0 comments on commit 017b671

Please sign in to comment.