`..new` is calculated wrong in lencode steps
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- r
- Domain
- documentation, machine-learning
Research direction
Start at the embed:::glm_coefs entry point shown in the example and trace how the ..new level is calculated. Use the supplied unbalanced-data example to verify that ..new reflects the global trimmed mean rather than the mean of coefficients, then update the related documentation accordingly.
Written by the indexing model from the issue text.
Description
The unseen levels are calculated based on the mean of the coeficients rather than the mean of global data. This should be fixed to better reflect the literature.
Make sure that the documentation is changed accordingly.
This change will be easily backward compatible as it changes how new values will change only.
data <- data.frame(
outcome = rnorm(1000) + c(rep(10, 900), rep(0, 100)),
predictor = c(rep("Big", 900), rep(letters[1:10], each = 10))
)
library(tidyverse)
data |>
count(predictor)
#> predictor n
#> 1 Big 900
#> 2 a 10
#> 3 b 10
#> 4 c 10
#> 5 d 10
#> 6 e 10
#> 7 f 10
#> 8 g 10
#> 9 h 10
#> 10 i 10
#> 11 j 10
data |>
summarize(
mean = mean(outcome),
.by = predictor
)
#> predictor mean
#> 1 Big 9.92621834
#> 2 a -0.12884918
#> 3 b 0.24802560
#> 4 c 0.12339453
#> 5 d 0.33307724
#> 6 e 0.08705590
#> 7 f 0.86433875
#> 8 g 0.42452332
#> 9 h 0.42548890
#> 10 i -0.07257279
#> 11 j -0.67403943
embed:::glm_coefs(y = select(data, outcome), x = pull(data, predictor))
#> # A tibble: 12 × 2
#> ..level ..value
#> <chr> <dbl>
#> 1 a -0.129
#> 2 b 0.248
#> 3 Big 9.93
#> 4 c 0.123
#> 5 d 0.333
#> 6 e 0.0871
#> 7 f 0.864
#> 8 g 0.425
#> 9 h 0.425
#> 10 i -0.0726
#> 11 j -0.674
#> 12 ..new 0.256
mean(data$outcome, trim = 0.1)
#> [1] 9.717217
- Dominant language
- R
- Stars
- 146
- Forks
- 23
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from tidymodels/embed
-
documentation
Difficulty 1/5 Under an hour Newbie friendliness 90/100
tidymodels/embed#277 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 58/100
tidymodels/embed#278 ·
-
feature
Difficulty 5/5 Over a week Newbie friendliness 45/100
tidymodels/embed#275 · 5 comments ·
-
feature
Difficulty 5/5 Over a week Newbie friendliness 25/100
tidymodels/embed#274 ·
-
documentation
Difficulty 4/5 3-5 days Newbie friendliness 35/100
tidymodels/embed#256 ·
All issues in tidymodels/embed
Similar issues
-
documentation pkg infrastructure
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
epiverse-trace/epiparameter#511 ·
-
function:write_dwc
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Urgent request: Due to vulnerabilities move to API version 12.6.1 (12.6.2 eventually) or 13.1.1 Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
jbkunst/highcharter#849 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
r-lib/pkgdepends#485 · 3 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100