Skip to content

Cubist: "subscript out of bounds" or "evaluation nested too deeply" #98

@frankiethull

Description

@frankiethull

The problem

I'm having trouble with cubist depending which computer I use. I was trying to reprex the second issue and stumbled into the first.

  1. converting cubist fits to orbital objects created a "subscript out of bounds" error on my linux laptop, 2) that conversion worked on my work laptop, but there was a downstream issue with orbital_sql/predict that stated "evaluation nested too deeply" which is a windows laptop.

Reproducible example

################################################################
#                       cubist orb 
################################################################
library(Cubist)
#> Loading required package: lattice
library(rules)
#> Loading required package: parsnip
library(orbital)
library(duckdb)
#> Loading required package: DBI

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

crf_spec <- parsnip::cubist_rules(
  committees = 95, 
  max_rules = 99,
  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)


crf_orb <- orbital::orbital(crf_fit)
#> Error in `map()`:
#> ℹ In index: 4.
#> Caused by error in `path[[1]]`:
#> ! subscript out of bounds

################################################################
#                    in memory duckdb 
################################################################

penquack_con <- dbConnect(duckdb(dbdir = ":memory:"))
model_table <- dplyr::copy_to(penquack_con, model_df)

# TODO, recreate `Error: evaluation nested too deeply: infinite recursion / options(expressions=)?`
crf_sql <- orbital::orbital_sql(crf_orb, penquack_con)
#> Error: object 'crf_orb' not found

### w/ orbital
tictoc::tic()
# TODO, recreate `Error: evaluation nested too deeply: infinite recursion / options(expressions=)?`
predict(crf_orb, model_table)
#> Error: object 'crf_orb' not found
tictoc::toc()
#> 0.001 sec elapsed

### w/o orbital
tictoc::tic()
predict(crf_fit, model_df)
#> # A tibble: 333 × 1
#>    .pred
#>    <dbl>
#>  1 3682.
#>  2 3532.
#>  3 3345.
#>  4 3554.
#>  5 3691.
#>  6 3540.
#>  7 4126.
#>  8 3419.
#>  9 3759.
#> 10 4144.
#> # ℹ 323 more rows
tictoc::toc()
#> 0.032 sec elapsed

Created on 2025-07-30 with reprex v2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions