spsanderson / tidyAML

Auto ML for the tidyverse
http://www.spsanderson.com/tidyAML/
Other
63 stars 7 forks source link

Add plot for `extract_regression_residuals()` #217

Closed spsanderson closed 7 months ago

spsanderson commented 7 months ago

Need to add a plotting function for the extract_regression_residuals()

Example code and output:

resid_tbl <- extract_regression_residuals(frt_tbl, TRUE)

resid_tbl |>
  map(\(x) x |>
        group_by(name) |>
        mutate(x = row_number()) |>
        ungroup() |>
        mutate(plot_group = ifelse(name == ".resid", "Residuals", "Actual and Predictions")) |>
        ggplot(aes(x = x, y = value, group = name, color = name)) +
        geom_line() +
        theme_minimal() +
        facet_wrap(~ plot_group, ncol = 1, scales = "free") +
        labs(
          x = "",
          y = "Value",
          title = "Actual, Predicted, and Residual Values by Model Type",
          subtitle = x$.model_type[1],
          color = "Data Type"
        )
  )

image

spsanderson commented 7 months ago

This needs to handle if the data is in long format or wide format