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

https://github.com/paithiov909/baritsu

Wrappers for the 'mlpack' R package; at times and in some situations, baritsu may be more powerful than a swiss army knife
https://github.com/paithiov909/baritsu

r r-package tidymodels

Last synced: 6 months ago
JSON representation

Wrappers for the 'mlpack' R package; at times and in some situations, baritsu may be more powerful than a swiss army knife

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%"
)
pkgload::load_all()
```

# baritsu

[![baritsu status badge](https://paithiov909.r-universe.dev/badges/baritsu)](https://paithiov909.r-universe.dev/baritsu)
[![R-CMD-check](https://github.com/paithiov909/baritsu/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/paithiov909/baritsu/actions/workflows/R-CMD-check.yaml)
[![codecov](https://codecov.io/gh/paithiov909/baritsu/branch/main/graph/badge.svg?token=LWH2AFDEMY)](https://app.codecov.io/gh/paithiov909/baritsu)
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)

The main goal of baritsu is to implement wrappers for [mlpack](https://www.mlpack.org/doc/stable/r_documentation.html) that allows formula as their argument.
Also, baritsu provides [parsnip](https://parsnip.tidymodels.org/) engines of those wrappers, so they can be used with [tidymodels](https://www.tidymodels.org/) workflows.

## Installation

You can install the development version of baritsu from [GitHub](https://github.com/) with:

``` r
remotes::install_github("paithiov909/baritsu")
```

## Example

This is a basic example which shows you how to solve a common problem:

```{r example}
suppressPackageStartupMessages({
require(tidymodels)
require(baritsu)
})

data("penguins", package = "modeldata")

set.seed(1218)
data_split <- initial_split(penguins, strata = species)
penguins_train <- training(data_split)
penguins_test <- testing(data_split)

rec <-
recipe(
species ~ .,
data = penguins_train
) |>
step_impute_median(all_numeric_predictors()) |>
step_impute_mode(all_nominal_predictors())

spec <-
decision_tree(
tree_depth = 0,
min_n = 5
) |>
set_engine("baritsu") |>
set_mode("classification")

translate(spec)

wf_fit <- workflow() |>
add_recipe(rec) |>
add_model(spec) |>
fit(penguins_train)

pred <- augment(wf_fit, penguins_test) |>
dplyr::select(species, .pred_class)

pred

f_meas(pred, truth = species, estimate = .pred_class)
```