Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tidymodels/brulee
High-Level Modeling Functions with 'torch'
https://github.com/tidymodels/brulee
Last synced: 3 days ago
JSON representation
High-Level Modeling Functions with 'torch'
- Host: GitHub
- URL: https://github.com/tidymodels/brulee
- Owner: tidymodels
- License: other
- Created: 2020-08-19T21:34:01.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-10-21T19:22:46.000Z (22 days ago)
- Last Synced: 2024-10-31T22:03:14.592Z (12 days ago)
- Language: R
- Homepage: https://brulee.tidymodels.org/
- Size: 7.71 MB
- Stars: 67
- Watchers: 9
- Forks: 7
- Open Issues: 9
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
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%"
)
```[![R-CMD-check](https://github.com/tidymodels/brulee/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/tidymodels/brulee/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/tidymodels/brulee/branch/main/graph/badge.svg)](https://app.codecov.io/gh/tidymodels/brulee?branch=main)
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html)The R `brulee` package contains several basic modeling functions that use the `torch` package infrastructure, such as:
* [neural networks](https://brulee.tidymodels.org/reference/brulee_mlp.html)
* [linear regression](https://brulee.tidymodels.org/reference/brulee_linear_reg.html)
* [logistic regression](https://brulee.tidymodels.org/reference/brulee_logistic_reg.html)
* [multinomial regression](https://brulee.tidymodels.org/reference/brulee_multinomial_reg.html)## Installation
You can install the released version of brulee from [CRAN](https://CRAN.R-project.org) with:
``` r
install.packages("brulee")
```And the development version from [GitHub](https://github.com/tidymodels/brulee) with:
``` r
# install.packages("pak")
pak::pak("tidymodels/brulee")
```
## Example`brulee` has formula, x/y, and recipe user interfaces for each function. For example:
```{r load, include = FALSE}
library(brulee)
library(yardstick)
library(recipes)
```
```{r class-fit-form}
library(brulee)
library(recipes)
library(yardstick)data(bivariate, package = "modeldata")
set.seed(20)
nn_log_biv <- brulee_mlp(Class ~ log(A) + log(B), data = bivariate_train,
epochs = 150, hidden_units = 3)# We use the tidymodels semantics to always return a tibble when predicting
predict(nn_log_biv, bivariate_test, type = "prob") %>%
bind_cols(bivariate_test) %>%
roc_auc(Class, .pred_One)
```A recipe can also be used if the data require some sort of preprocessing (e.g., indicator variables, transformations, or standardization):
```{r class-fit-rec}
library(recipes)rec <-
recipe(Class ~ ., data = bivariate_train) %>%
step_YeoJohnson(all_numeric_predictors()) %>%
step_normalize(all_numeric_predictors())set.seed(20)
nn_rec_biv <- brulee_mlp(rec, data = bivariate_train,
epochs = 150, hidden_units = 3)# A little better
predict(nn_rec_biv, bivariate_test, type = "prob") %>%
bind_cols(bivariate_test) %>%
roc_auc(Class, .pred_One)
```## Code of Conduct
Please note that the brulee project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/0/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.