Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/curso-r/treesnip

Parsnip backends for `tree`, `lightGBM` and `Catboost`
https://github.com/curso-r/treesnip

Last synced: about 2 months ago
JSON representation

Parsnip backends for `tree`, `lightGBM` and `Catboost`

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
library(magrittr)
library(magrittr)
library(knitr)
library(kableExtra)
```

# treesnip

[![R build status](https://github.com/curso-r/treesnip/workflows/R-CMD-check/badge.svg)](https://github.com/curso-r/treesnip)
[![Codecov test coverage](https://codecov.io/gh/curso-r/treesnip/branch/master/graph/badge.svg)](https://app.codecov.io/gh/curso-r/treesnip?branch=master)
[![R-CMD-check](https://github.com/curso-r/treesnip/workflows/R-CMD-check/badge.svg)](https://github.com/curso-r/treesnip/actions)
[![R-CMD-check](https://github.com/curso-r/treesnip/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/curso-r/treesnip/actions/workflows/R-CMD-check.yaml)

This package provides the following bindings for parsnip package:

- the `tree` engine for `decision_tree`;
- the `catboost` engine for `boost_tree` - only available in `catboost` branch. See [catboost](#catboost);
- the `lightGBM` engine for `boost_tree`.

**Note that the development of this package has shifted to the [bonsai package](https://github.com/tidymodels/bonsai). We suggest filing issues and/or pull requests there.**

## docs

- [tree package docs](https://cran.r-project.org/web/packages/tree/tree.pdf)
- [LightGBM docs](https://lightgbm.readthedocs.io/)
- [Catboost docs](https://catboost.ai/docs/)

## Installation

Not on CRAN yet.

``` r
remotes::install_github("curso-r/treesnip")
```

See [catboost](#catboost) to use with `catboost`.

## Minimal Example

``` r
# decision_tree
model <- parsnip::decision_tree()
parsnip::set_engine(model, "tree")

# boost_tree
model <- parsnip::boost_tree(mtry = 1, trees = 50)

parsnip::set_engine(model, "catboost")
parsnip::set_engine(model, "lightgbm")
```

## Hyperparameters map

**decision_tree()**

```{r, echo=FALSE}
tibble::tribble(
~ parsnip, ~tree,
"min_n", "minsize",
"cost_complexity", "mindev"
) %>% knitr::kable()
```

**boost_tree()**

```{r, echo=FALSE, warning=FALSE, message=FALSE}
tibble::tribble(
~ parsnip, ~catboost, ~lightGBM,
'mtry', 'rsm', 'feature_fraction',
'trees', 'iterations', 'num_iterations',
'min_n', 'min_data_in_leaf', 'min_data_in_leaf',
'tree_depth', 'depth', 'max_depth',
'learn_rate', 'learning_rate', 'learning_rate',
'loss_reduction', cell_spec('Not found', color = 'red', bold = TRUE), 'min_gain_to_split',
'sample_size', 'subsample', 'bagging_fraction'
) %>% kable(escape = FALSE)
```

## Catboost

Originally `treesnip` had support for both `lightgbm` and `catboost`. Since `catboost` has no intent to make it to CRAN we removed the parsnip implementation from the main package. You can still use it from the `catboost` branch that we will keep up to date with the main branch.

The `catboost` branch can be installed with:

```
remotes::install_github("curso-r/treesnip@catboost")
```