Skip to content

Conversation

EmilHvitfeldt
Copy link
Member

In reference to tidymodels/orbital#98

library(Cubist)
#> Loading required package: lattice
library(rules)
#> Loading required package: parsnip
library(orbital)

model_df <- modeldata::penguins |> na.omit()

crf_spec <- parsnip::cubist_rules(
  committees = 2,
  max_rules = 5,
  neighbors = 2
) |>
  parsnip::set_engine("Cubist") |>
  parsnip::set_mode("regression")

crf_rec <- recipes::recipe(body_mass_g ~ ., model_df) |>
  recipes::step_dummy(recipes::all_nominal_predictors()) |>
  recipes::step_nzv(recipes::all_predictors())


crf_wkflw <- workflows::workflow() |>
  workflows::add_model(crf_spec) |>
  workflows::add_recipe(crf_rec)

crf_fit <- crf_wkflw |>
  workflows::fit(model_df)

orbital::orbital(crf_fit)
#> 
#> ── orbital Object ──────────────────────────────────────────────────────────────
#> • island_Dream = as.numeric(island == "Dream")
#> • island_Torgersen = as.numeric(island == "Torgersen")
#> • sex_male = as.numeric(sex == "male")
#> • .pred = (ifelse(flipper_length_mm < 202, -320.8 + bill_depth_mm * 64 + ...
#> ────────────────────────────────────────────────────────────────────────────────
#> 4 equations in total.

Created on 2025-10-15 with reprex v2.1.1

@EmilHvitfeldt EmilHvitfeldt merged commit 28b473e into main Oct 21, 2025
7 checks passed
@EmilHvitfeldt EmilHvitfeldt deleted the cubist-stumps branch October 21, 2025 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant