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

no applicable method for 'extract_fit_time' applied to an object of class "c('_lm', 'model_fit') #1234

Closed
chillerb opened this issue Jan 24, 2025 · 3 comments

Comments

@chillerb
Copy link

The problem

I'm having trouble with extracting the fit time from a parsnip model.
It does not seem to find the associated S3method.

Reproducible example

library(tidymodels)

sim_data <- modeldata::sim_regression()

linear_spec <- linear_reg(mode = "regression")

lm_fit <- fit(linear_spec, outcome ~ ., sim_data)
 extract_fit_time(lm_fit)
#> Error in UseMethod("extract_fit_time"): no applicable method for 'extract_fit_time' applied to an object of class "c('_lm', 'model_fit')"

Created on 2025-01-24 with reprex v2.1.1

Session info

sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.4.1 (2024-06-14)
#>  os       Ubuntu 22.04.5 LTS
#>  system   x86_64, linux-gnu
#>  ui       X11
#>  language (EN)
#>  collate  en_US.UTF-8
#>  ctype    en_US.UTF-8
#>  tz       Etc/UTC
#>  date     2025-01-24
#>  pandoc   3.4 @ /usr/bin/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  ! package      * version    date (UTC) lib source
#>    backports      1.5.0      2024-05-23 [1] CRAN (R 4.4.1)
#>  P broom        * 1.0.7      2024-09-26 [?] CRAN (R 4.4.1)
#>  P class          7.3-23     2025-01-01 [?] CRAN (R 4.4.1)
#>  P cli            3.6.3      2024-06-21 [?] CRAN (R 4.4.1)
#>  P codetools      0.2-20     2024-03-31 [3] CRAN (R 4.4.1)
#>    colorspace     2.1-1      2024-07-26 [1] CRAN (R 4.4.1)
#>    data.table     1.16.4     2024-12-06 [1] CRAN (R 4.4.1)
#>  P dials        * 1.3.0      2024-07-30 [?] CRAN (R 4.4.1)
#>  P DiceDesign     1.10       2023-12-07 [?] CRAN (R 4.4.1)
#>  P digest         0.6.37     2024-08-19 [?] CRAN (R 4.4.1)
#>  P dplyr        * 1.1.4      2023-11-17 [?] CRAN (R 4.4.1)
#>  P evaluate       1.0.3      2025-01-10 [?] CRAN (R 4.4.1)
#>  P fastmap        1.2.0      2024-05-15 [?] CRAN (R 4.4.1)
#>    foreach        1.5.2      2022-02-02 [1] CRAN (R 4.4.1)
#>  P fs             1.6.5      2024-10-30 [?] CRAN (R 4.4.1)
#>  P furrr          0.3.1      2022-08-15 [?] CRAN (R 4.4.1)
#>  P future         1.34.0     2024-07-29 [?] CRAN (R 4.4.1)
#>  P future.apply   1.11.3     2024-10-27 [?] CRAN (R 4.4.1)
#>  P generics       0.1.3      2022-07-05 [?] CRAN (R 4.4.1)
#>    ggplot2      * 3.5.1      2024-04-23 [1] CRAN (R 4.4.1)
#>  P globals        0.16.3     2024-03-08 [?] CRAN (R 4.4.1)
#>    glue           1.8.0      2024-09-30 [1] CRAN (R 4.4.1)
#>  P gower          1.0.2      2024-12-17 [?] CRAN (R 4.4.1)
#>  P GPfit          1.0-8      2019-02-08 [?] CRAN (R 4.4.1)
#>    gtable         0.3.6      2024-10-25 [1] CRAN (R 4.4.1)
#>  P hardhat        1.4.0      2024-06-02 [?] CRAN (R 4.4.1)
#>  P htmltools      0.5.8.1    2024-04-04 [?] CRAN (R 4.4.1)
#>  P infer        * 1.0.7      2024-03-25 [?] CRAN (R 4.4.1)
#>  P ipred          0.9-15     2024-07-18 [?] CRAN (R 4.4.1)
#>    iterators      1.0.14     2022-02-05 [1] CRAN (R 4.4.1)
#>  P knitr          1.49       2024-11-08 [?] CRAN (R 4.4.1)
#>  P lattice        0.22-6     2024-03-20 [3] CRAN (R 4.4.1)
#>  P lava           1.8.1      2025-01-12 [?] CRAN (R 4.4.1)
#>  P lhs            1.2.0      2024-06-30 [?] CRAN (R 4.4.1)
#>  P lifecycle      1.0.4      2023-11-07 [?] CRAN (R 4.4.1)
#>  P listenv        0.9.1      2024-01-29 [?] CRAN (R 4.4.1)
#>  P lubridate      1.9.4      2024-12-08 [?] CRAN (R 4.4.1)
#>  P magrittr       2.0.3      2022-03-30 [?] CRAN (R 4.4.1)
#>  P MASS           7.3-64     2025-01-04 [?] CRAN (R 4.4.1)
#>  P Matrix         1.7-1      2024-10-18 [?] CRAN (R 4.4.1)
#>  P modeldata    * 1.4.0      2024-06-19 [?] CRAN (R 4.4.1)
#>    munsell        0.5.1      2024-04-01 [1] CRAN (R 4.4.1)
#>  P nnet           7.3-20     2025-01-01 [?] CRAN (R 4.4.1)
#>  P parallelly     1.41.0     2024-12-18 [?] CRAN (R 4.4.1)
#>  P parsnip      * 1.2.1      2024-03-22 [?] CRAN (R 4.4.1)
#>    pillar         1.10.1     2025-01-07 [1] CRAN (R 4.4.1)
#>  P pkgconfig      2.0.3      2019-09-22 [?] CRAN (R 4.4.1)
#>  P prodlim        2024.06.25 2024-06-24 [?] CRAN (R 4.4.1)
#>  P purrr        * 1.0.2      2023-08-10 [?] CRAN (R 4.4.1)
#>  P R6             2.5.1      2021-08-19 [?] CRAN (R 4.4.1)
#>    Rcpp           1.0.14     2025-01-12 [1] CRAN (R 4.4.1)
#>  P recipes      * 1.1.0      2024-07-04 [?] CRAN (R 4.4.1)
#>  P reprex         2.1.1      2024-07-06 [?] CRAN (R 4.4.1)
#>    rlang          1.1.5      2025-01-17 [1] CRAN (R 4.4.1)
#>  P rmarkdown      2.29       2024-11-04 [?] CRAN (R 4.4.1)
#>  P rpart          4.1.24     2025-01-07 [?] CRAN (R 4.4.1)
#>  P rsample      * 1.2.1      2024-03-25 [?] CRAN (R 4.4.1)
#>  P rstudioapi     0.17.1     2024-10-22 [?] CRAN (R 4.4.1)
#>  P scales       * 1.3.0      2023-11-28 [?] CRAN (R 4.4.1)
#>  P sessioninfo    1.2.2      2021-12-06 [?] CRAN (R 4.4.1)
#>  P survival       3.8-3      2024-12-17 [?] CRAN (R 4.4.1)
#>  P tibble       * 3.2.1      2023-03-20 [?] CRAN (R 4.4.1)
#>  P tidymodels   * 1.2.0      2024-03-25 [?] CRAN (R 4.4.1)
#>  P tidyr        * 1.3.1      2024-01-24 [?] CRAN (R 4.4.1)
#>  P tidyselect     1.2.1      2024-03-11 [?] CRAN (R 4.4.1)
#>  P timechange     0.3.0      2024-01-18 [?] CRAN (R 4.4.1)
#>  P timeDate       4041.110   2024-09-22 [?] CRAN (R 4.4.1)
#>  P tune         * 1.2.1      2024-04-18 [?] CRAN (R 4.4.1)
#>  P vctrs          0.6.5      2023-12-01 [?] CRAN (R 4.4.1)
#>    withr          3.0.2      2024-10-28 [1] CRAN (R 4.4.1)
#>  P workflows    * 1.1.4      2024-02-19 [?] CRAN (R 4.4.1)
#>  P workflowsets * 1.1.0      2024-03-21 [?] CRAN (R 4.4.1)
#>  P xfun           0.50       2025-01-07 [?] CRAN (R 4.4.1)
#>  P yaml           2.3.10     2024-07-26 [?] CRAN (R 4.4.1)
#>  P yardstick    * 1.3.1      2024-03-21 [?] CRAN (R 4.4.1)
#> 
#>  [1] /root/.cache/R/renv/library/rabaki-e6dba559/linux-ubuntu-jammy/R-4.4/x86_64-pc-linux-gnu
#>  [2] /root/.cache/R/renv/sandbox/linux-ubuntu-jammy/R-4.4/x86_64-pc-linux-gnu/25ebdc09
#>  [3] /usr/local/lib/R/library
#> 
#>  P ── Loaded and on-disk path mismatch.
#> 
#> ──────────────────────────────────────────────────────────────────────────────
@topepo
Copy link
Member

topepo commented Jan 28, 2025

This appears to be fixed in the devel version of parsnip (which will go to CRAN within a week).

library(tidymodels)

sim_data <- modeldata::sim_regression()

linear_spec <- linear_reg(mode = "regression")

lm_fit <- fit(linear_spec, outcome ~ ., sim_data)
extract_fit_time(lm_fit)
#> # A tibble: 1 × 2
#>   stage_id   elapsed
#>   <chr>        <dbl>
#> 1 linear_reg 0.00200

Created on 2025-01-28 with reprex v2.1.0

@topepo topepo closed this as completed Jan 28, 2025
@chillerb
Copy link
Author

Alright, thanks! I was kind of confused, why the method wasn't showing up in my locally installed parsnip version.

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 12, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants