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

subsetting of outcome when outcome has label #1061

Closed
simonpcouch opened this issue Feb 2, 2024 · 1 comment · Fixed by #1062
Closed

subsetting of outcome when outcome has label #1061

simonpcouch opened this issue Feb 2, 2024 · 1 comment · Fixed by #1062
Labels
bug an unexpected problem or unintended behavior

Comments

@simonpcouch
Copy link
Contributor

When I was trying to reproduce #1060, this was my first go at a minimal reprex. There's no error here (at least for this engine), but parsnip takes only the first observation (and I'm assuming it's recycled later on?)

library(parsnip)

fit_xy(
  linear_reg(),
  data.frame(x = 1:5),
  y = structure(2:6, label = "hi")
)
#> parsnip model object
#> 
#> 
#> Call:
#> stats::lm(formula = ..y ~ ., data = data)
#> 
#> Coefficients:
#> (Intercept)            x  
#>   2.000e+00    1.573e-16

Created on 2024-02-02 with reprex v2.1.0

Notice intercept is 2 and slope is basically zero. This is because the outcome is always 2:6[[1]]😬

Offending code:

parsnip/R/fit.R

Lines 270 to 276 in 8ccf1be

if (object$engine != "spark" & NCOL(y) == 1 & !(is.vector(y) | is.factor(y))) {
if (is.matrix(y)) {
y <- y[, 1]
} else {
y <- y[[1]]
}
}

@simonpcouch simonpcouch added the bug an unexpected problem or unintended behavior label Feb 2, 2024
Copy link

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Feb 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant