Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

step_collapse_cart() gives uninformative results when using outcome wrongly #228

Open
EmilHvitfeldt opened this issue Sep 11, 2024 · 0 comments
Labels
feature a feature request or enhancement

Comments

@EmilHvitfeldt
Copy link
Member

library(embed)
library(modeldata)

# no outcome - bad error
recipe(Street ~., data = ames) |>
  step_collapse_cart(Neighborhood) |>
  prep() 
#> Error in `step_collapse_cart()`:
#> Caused by error in `purrr::map2()`:
#> ℹ In index: 1.
#> ℹ With name: Neighborhood.
#> Caused by error in `training[[y_name]]`:
#> ! Can't extract column with `y_name`.
#> ✖ Subscript `y_name` must be size 1, not 0.

# multiple outcomes - bad error
recipe(Street ~., data = ames) |>
  step_collapse_cart(Neighborhood, outcome = vars(MS_SubClass, MS_Zoning)) |>
  prep() 
#> Error in `step_collapse_cart()`:
#> Caused by error in `purrr::map2()`:
#> ℹ In index: 1.
#> ℹ With name: Neighborhood.
#> Caused by error in `training[[y_name]]`:
#> ! Can't extract column with `y_name`.
#> ✖ Subscript `y_name` must be size 1, not 2.

# factor outcome - disregarded
recipe(Street ~., data = ames) |>
  step_collapse_cart(Neighborhood, outcome = vars(Street)) |>
  prep() 
#> 
#> ── Recipe ──────────────────────────────────────────────────────────────────────
#> 
#> ── Inputs
#> Number of variables by role
#> outcome:    1
#> predictor: 73
#> 
#> ── Training information
#> Training data contained 2930 data points and no incomplete rows.
#> 
#> ── Operations
#> • Collapsing factor levels using CART: <none> | Trained

# numeric outcome - expected
recipe(Street ~., data = ames) |>
  step_collapse_cart(Neighborhood, outcome = vars(Sale_Price)) |>
  prep() 
#> 
#> ── Recipe ──────────────────────────────────────────────────────────────────────
#> 
#> ── Inputs
#> Number of variables by role
#> outcome:    1
#> predictor: 73
#> 
#> ── Training information
#> Training data contained 2930 data points and no incomplete rows.
#> 
#> ── Operations
#> • Collapsing factor levels using CART: Neighborhood | Trained

Created on 2024-09-11 with reprex v2.1.1

@EmilHvitfeldt EmilHvitfeldt added the feature a feature request or enhancement label Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

1 participant