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

Add an argument of .pivot_long to extract_regression_residuals #198

Closed
spsanderson opened this issue Dec 21, 2023 · 0 comments
Closed

Add an argument of .pivot_long to extract_regression_residuals #198

spsanderson opened this issue Dec 21, 2023 · 0 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@spsanderson
Copy link
Owner

spsanderson commented Dec 21, 2023

Add and argument of .pivot_wide as a boolean (TRUE/FALSE) that will pivot the residuals wide if user desires it to.

Example:

> library(recipes, quietly = TRUE)
> library(tidyAML)
> 
> rec_obj <- recipe(mpg ~ ., data = mtcars)
> 
> fr_tbl <- fast_regression(mtcars, rec_obj, .parsnip_eng = c("lm","glm"),
+                           .parsnip_fns = "linear_reg")
> 
> result <- extract_regression_residuals(fr_tbl)
> 
> purrr::map(result, ~tidyr::pivot_longer(
+   data = .x,
+   cols = -.model_type
+ ))
[[1]]
# A tibble: 96 × 3
   .model_type     name       value
   <chr>           <chr>      <dbl>
 1 lm - linear_reg .actual    21   
 2 lm - linear_reg .predicted 16.6 
 3 lm - linear_reg .resid      4.42
 4 lm - linear_reg .actual    21   
 5 lm - linear_reg .predicted 14.2 
 6 lm - linear_reg .resid      6.82
 7 lm - linear_reg .actual    22.8 
 8 lm - linear_reg .predicted 24.2 
 9 lm - linear_reg .resid     -1.37
10 lm - linear_reg .actual    21.4 
# ℹ 86 more rows
# ℹ Use `print(n = ...)` to see more rows

[[2]]
# A tibble: 96 × 3
   .model_type      name       value
   <chr>            <chr>      <dbl>
 1 glm - linear_reg .actual    21   
 2 glm - linear_reg .predicted 16.6 
 3 glm - linear_reg .resid      4.42
 4 glm - linear_reg .actual    21   
 5 glm - linear_reg .predicted 14.2 
 6 glm - linear_reg .resid      6.82
 7 glm - linear_reg .actual    22.8 
 8 glm - linear_reg .predicted 24.2 
 9 glm - linear_reg .resid     -1.37
10 glm - linear_reg .actual    21.4 
# ℹ 86 more rows
# ℹ Use `print(n = ...)` to see more rows
@spsanderson spsanderson added the enhancement New feature or request label Dec 21, 2023
@spsanderson spsanderson self-assigned this Dec 21, 2023
@spsanderson spsanderson changed the title Add an argument of .pivot_wide to extract_regression_residuals Add an argument of .pivot_long to extract_regression_residuals Dec 29, 2023
@spsanderson spsanderson added this to the tidyAML 0.0.4 milestone Dec 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

No branches or pull requests

1 participant