tidymodels / tidymodels/embed

`step_lencode_*()` gives non-ideal errors when applied to constant vectors

Open
#229 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature target encoding
Dominant language
R
Stars
146
Forks
23
PR merge metrics
No merged PRs in 30d

Description

library(embed)
library(modeldata)

ames$const <- "red"

recipe(Street ~ const, data = ames) |>
  step_lencode_glm(const, outcome = vars(Street)) |>
  prep()
#> Error in `step_lencode_glm()`:
#> Caused by error in `purrr::map()`:
#> ℹ In index: 1.
#> ℹ With name: const.
#> Caused by error in `contrasts<-`:
#> ! contrasts can be applied only to factors with 2 or more levels

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the constant-vector example from the issue, then inspect the step_lencode_*() implementations and their existing tests to identify where the contrasts error originates. Done should mean that applying these steps to a constant predictor produces an intentional, user-facing result rather than the current low-level error.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.