Skip to content

Commit b1b0a1b

Browse files
committed
prep for CRAN release.
1 parent f3baa09 commit b1b0a1b

13 files changed

+160
-106
lines changed

DESCRIPTION

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,6 @@ Imports:
5656
tidyr,
5757
broom,
5858
ggplot2,
59-
magrittr
60-
RoxygenNote: 7.3.1
59+
magrittr,
60+
tune (>= 1.3.0)
61+
RoxygenNote: 7.3.2

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export(enquo)
1414
export(enquos)
1515
export(extract_model_spec)
1616
export(extract_regression_residuals)
17+
export(extract_tunable_params)
1718
export(extract_wflw)
1819
export(extract_wflw_fit)
1920
export(extract_wflw_pred)

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ None
66
## New Features
77
1. Fix #242 - Add function `quantile_normalize()`.
88
2. Fix #243 - Add function `check_duplicate_rows()`.
9+
3. Fix #248 - Add function `extract_tunable_params()`.
910

1011
## Minor Fixes and Improvements
1112
1. Fix #239 - Fix erroneous documentation for `plot_regression_predictions()`.

R/extract-tunable-params.R

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,19 @@
1515
#'
1616
#' @examples
1717
#' library(dplyr)
18-
#' mods <- create_model_spec(.parsnip_eng = list("lm", "glmnet"))
18+
#' mods <- fast_regression_parsnip_spec_tbl(
19+
#' .parsnip_fns = "linear_reg",
20+
#' .parsnip_eng = c("lm","glmnet")
21+
#' )
1922
#' extract_tunable_params(mods)
2023
#'
2124
#' @export
2225
extract_tunable_params <- function(.model_tbl) {
23-
26+
2427
# Tidyeval ----
2528
model_tbl <- .model_tbl
2629
model_tbl_class <- class(model_tbl)
27-
30+
2831
# Checks ----
2932
if (!inherits(model_tbl, "tidyaml_mod_spec_tbl")){
3033
rlang::abort(
@@ -36,31 +39,31 @@ extract_tunable_params <- function(.model_tbl) {
3639
use_cli_format = TRUE
3740
)
3841
}
39-
42+
4043
# Manipulation
4144
model_factor_tbl <- model_tbl |>
4245
dplyr::mutate(.model_id = forcats::as_factor(.model_id))
43-
46+
4447
# Make a group split object list
4548
models_list <- model_factor_tbl |>
4649
dplyr::group_split(.model_id)
47-
50+
4851
# Extract tunable parameters using purrr imap
4952
tunable_params_list <- models_list |>
5053
purrr::imap(
5154
.f = function(obj, id) {
52-
55+
5356
# Pull the model_spec column and then pluck the model_spec
5457
mod <- obj |> dplyr::pull(5) |> purrr::pluck(1)
5558

5659
# Extract tunable parameters
57-
ret <- tunable(mod)
58-
60+
ret <- tune::tunable(mod)
61+
5962
# Return the result
6063
return(ret)
6164
}
6265
)
63-
66+
6467
# Return
6568
return(tunable_params_list)
6669
}

README.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ knitr::opts_chunk$set(
2020
![](https://cranlogs.r-pkg.org/badges/tidyAML)
2121
![](https://cranlogs.r-pkg.org/badges/grand-total/tidyAML)
2222
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html##experimental)
23-
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com)
23+
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://kentcdodds.github.io/makeapullrequest.com/)
2424
<!-- badges: end -->
2525

2626
## Introduction

README.md

Lines changed: 93 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
![](https://cranlogs.r-pkg.org/badges/grand-total/tidyAML) [![Lifecycle:
1111
experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html##experimental)
1212
[![PRs
13-
Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://makeapullrequest.com)
13+
Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://kentcdodds.github.io/makeapullrequest.com/)
1414
<!-- badges: end -->
1515

1616
## Introduction
@@ -272,15 +272,15 @@ frt_tbl$pred_wflw
272272
#> # A tibble: 64 × 3
273273
#> .data_category .data_type .value
274274
#> <chr> <chr> <dbl>
275-
#> 1 actual actual 15.2
276-
#> 2 actual actual 19.2
277-
#> 3 actual actual 22.8
278-
#> 4 actual actual 33.9
279-
#> 5 actual actual 26
280-
#> 6 actual actual 19.2
281-
#> 7 actual actual 15
282-
#> 8 actual actual 27.3
283-
#> 9 actual actual 24.4
275+
#> 1 actual actual 22.8
276+
#> 2 actual actual 15
277+
#> 3 actual actual 17.8
278+
#> 4 actual actual 18.7
279+
#> 5 actual actual 30.4
280+
#> 6 actual actual 26
281+
#> 7 actual actual 14.3
282+
#> 8 actual actual 19.2
283+
#> 9 actual actual 14.7
284284
#> 10 actual actual 17.3
285285
#> # ℹ 54 more rows
286286
#>
@@ -291,15 +291,15 @@ frt_tbl$pred_wflw
291291
#> # A tibble: 64 × 3
292292
#> .data_category .data_type .value
293293
#> <chr> <chr> <dbl>
294-
#> 1 actual actual 15.2
295-
#> 2 actual actual 19.2
296-
#> 3 actual actual 22.8
297-
#> 4 actual actual 33.9
298-
#> 5 actual actual 26
299-
#> 6 actual actual 19.2
300-
#> 7 actual actual 15
301-
#> 8 actual actual 27.3
302-
#> 9 actual actual 24.4
294+
#> 1 actual actual 22.8
295+
#> 2 actual actual 15
296+
#> 3 actual actual 17.8
297+
#> 4 actual actual 18.7
298+
#> 5 actual actual 30.4
299+
#> 6 actual actual 26
300+
#> 7 actual actual 14.3
301+
#> 8 actual actual 19.2
302+
#> 9 actual actual 14.7
303303
#> 10 actual actual 17.3
304304
#> # ℹ 54 more rows
305305
```
@@ -322,16 +322,16 @@ extract_wflw_pred(frt_tbl, 1:3)
322322
#> # A tibble: 192 × 4
323323
#> .model_type .data_category .data_type .value
324324
#> <chr> <chr> <chr> <dbl>
325-
#> 1 lm - linear_reg actual actual 32.4
326-
#> 2 lm - linear_reg actual actual 14.3
327-
#> 3 lm - linear_reg actual actual 15.8
328-
#> 4 lm - linear_reg actual actual 30.4
329-
#> 5 lm - linear_reg actual actual 24.4
330-
#> 6 lm - linear_reg actual actual 15
331-
#> 7 lm - linear_reg actual actual 33.9
332-
#> 8 lm - linear_reg actual actual 22.8
333-
#> 9 lm - linear_reg actual actual 19.2
334-
#> 10 lm - linear_reg actual actual 21.4
325+
#> 1 lm - linear_reg actual actual 15.5
326+
#> 2 lm - linear_reg actual actual 19.2
327+
#> 3 lm - linear_reg actual actual 21.5
328+
#> 4 lm - linear_reg actual actual 14.3
329+
#> 5 lm - linear_reg actual actual 21.4
330+
#> 6 lm - linear_reg actual actual 21
331+
#> 7 lm - linear_reg actual actual 13.3
332+
#> 8 lm - linear_reg actual actual 15.2
333+
#> 9 lm - linear_reg actual actual 24.4
334+
#> 10 lm - linear_reg actual actual 10.4
335335
#> # ℹ 182 more rows
336336
```
337337

@@ -343,50 +343,50 @@ Getting residuals is easy with `{tidyAML}`. Let’s take a look.
343343
extract_regression_residuals(frt_tbl)
344344
#> [[1]]
345345
#> # A tibble: 32 × 4
346-
#> .model_type .actual .predicted .resid
347-
#> <chr> <dbl> <dbl> <dbl>
348-
#> 1 lm - linear_reg 32.4 27.5 4.94
349-
#> 2 lm - linear_reg 14.3 14.2 0.121
350-
#> 3 lm - linear_reg 15.8 18.5 -2.71
351-
#> 4 lm - linear_reg 30.4 30.6 -0.178
352-
#> 5 lm - linear_reg 24.4 22.6 1.82
353-
#> 6 lm - linear_reg 15 13.3 1.69
354-
#> 7 lm - linear_reg 33.9 29.3 4.64
355-
#> 8 lm - linear_reg 22.8 25.3 -2.53
356-
#> 9 lm - linear_reg 19.2 17.6 1.62
357-
#> 10 lm - linear_reg 21.4 21.2 0.162
346+
#> .model_type .actual .predicted .resid
347+
#> <chr> <dbl> <dbl> <dbl>
348+
#> 1 lm - linear_reg 15.5 16.5 -0.988
349+
#> 2 lm - linear_reg 19.2 19.7 -0.488
350+
#> 3 lm - linear_reg 21.5 21.6 -0.127
351+
#> 4 lm - linear_reg 14.3 14.1 0.157
352+
#> 5 lm - linear_reg 21.4 24.6 -3.23
353+
#> 6 lm - linear_reg 21 21.1 -0.0800
354+
#> 7 lm - linear_reg 13.3 13.8 -0.482
355+
#> 8 lm - linear_reg 15.2 17.7 -2.52
356+
#> 9 lm - linear_reg 24.4 22.3 2.11
357+
#> 10 lm - linear_reg 10.4 11.5 -1.14
358358
#> # ℹ 22 more rows
359359
#>
360360
#> [[2]]
361361
#> # A tibble: 32 × 4
362362
#> .model_type .actual .predicted .resid
363363
#> <chr> <dbl> <dbl> <dbl>
364-
#> 1 gee - linear_reg 32.4 27.5 4.95
365-
#> 2 gee - linear_reg 14.3 14.2 0.0928
366-
#> 3 gee - linear_reg 15.8 18.5 -2.67
367-
#> 4 gee - linear_reg 30.4 30.5 -0.147
368-
#> 5 gee - linear_reg 24.4 22.6 1.83
369-
#> 6 gee - linear_reg 15 13.3 1.68
370-
#> 7 gee - linear_reg 33.9 29.3 4.65
371-
#> 8 gee - linear_reg 22.8 25.3 -2.53
372-
#> 9 gee - linear_reg 19.2 17.6 1.60
373-
#> 10 gee - linear_reg 21.4 21.2 0.165
364+
#> 1 gee - linear_reg 15.5 16.4 -0.896
365+
#> 2 gee - linear_reg 19.2 19.2 0.0385
366+
#> 3 gee - linear_reg 21.5 22.3 -0.797
367+
#> 4 gee - linear_reg 14.3 14.6 -0.250
368+
#> 5 gee - linear_reg 21.4 24.6 -3.24
369+
#> 6 gee - linear_reg 21 21.1 -0.135
370+
#> 7 gee - linear_reg 13.3 13.8 -0.505
371+
#> 8 gee - linear_reg 15.2 17.4 -2.16
372+
#> 9 gee - linear_reg 24.4 22.6 1.80
373+
#> 10 gee - linear_reg 10.4 11.8 -1.39
374374
#> # ℹ 22 more rows
375375
#>
376376
#> [[3]]
377377
#> # A tibble: 32 × 4
378-
#> .model_type .actual .predicted .resid
379-
#> <chr> <dbl> <dbl> <dbl>
380-
#> 1 glm - linear_reg 32.4 27.5 4.94
381-
#> 2 glm - linear_reg 14.3 14.2 0.121
382-
#> 3 glm - linear_reg 15.8 18.5 -2.71
383-
#> 4 glm - linear_reg 30.4 30.6 -0.178
384-
#> 5 glm - linear_reg 24.4 22.6 1.82
385-
#> 6 glm - linear_reg 15 13.3 1.69
386-
#> 7 glm - linear_reg 33.9 29.3 4.64
387-
#> 8 glm - linear_reg 22.8 25.3 -2.53
388-
#> 9 glm - linear_reg 19.2 17.6 1.62
389-
#> 10 glm - linear_reg 21.4 21.2 0.162
378+
#> .model_type .actual .predicted .resid
379+
#> <chr> <dbl> <dbl> <dbl>
380+
#> 1 glm - linear_reg 15.5 16.5 -0.988
381+
#> 2 glm - linear_reg 19.2 19.7 -0.488
382+
#> 3 glm - linear_reg 21.5 21.6 -0.127
383+
#> 4 glm - linear_reg 14.3 14.1 0.157
384+
#> 5 glm - linear_reg 21.4 24.6 -3.23
385+
#> 6 glm - linear_reg 21 21.1 -0.0800
386+
#> 7 glm - linear_reg 13.3 13.8 -0.482
387+
#> 8 glm - linear_reg 15.2 17.7 -2.52
388+
#> 9 glm - linear_reg 24.4 22.3 2.11
389+
#> 10 glm - linear_reg 10.4 11.5 -1.14
390390
#> # ℹ 22 more rows
391391
```
392392

@@ -399,47 +399,47 @@ extract_regression_residuals(frt_tbl, .pivot_long = TRUE)
399399
#> # A tibble: 96 × 3
400400
#> .model_type name value
401401
#> <chr> <chr> <dbl>
402-
#> 1 lm - linear_reg .actual 32.4
403-
#> 2 lm - linear_reg .predicted 27.5
404-
#> 3 lm - linear_reg .resid 4.94
405-
#> 4 lm - linear_reg .actual 14.3
406-
#> 5 lm - linear_reg .predicted 14.2
407-
#> 6 lm - linear_reg .resid 0.121
408-
#> 7 lm - linear_reg .actual 15.8
409-
#> 8 lm - linear_reg .predicted 18.5
410-
#> 9 lm - linear_reg .resid -2.71
411-
#> 10 lm - linear_reg .actual 30.4
402+
#> 1 lm - linear_reg .actual 15.5
403+
#> 2 lm - linear_reg .predicted 16.5
404+
#> 3 lm - linear_reg .resid -0.988
405+
#> 4 lm - linear_reg .actual 19.2
406+
#> 5 lm - linear_reg .predicted 19.7
407+
#> 6 lm - linear_reg .resid -0.488
408+
#> 7 lm - linear_reg .actual 21.5
409+
#> 8 lm - linear_reg .predicted 21.6
410+
#> 9 lm - linear_reg .resid -0.127
411+
#> 10 lm - linear_reg .actual 14.3
412412
#> # ℹ 86 more rows
413413
#>
414414
#> [[2]]
415415
#> # A tibble: 96 × 3
416416
#> .model_type name value
417417
#> <chr> <chr> <dbl>
418-
#> 1 gee - linear_reg .actual 32.4
419-
#> 2 gee - linear_reg .predicted 27.5
420-
#> 3 gee - linear_reg .resid 4.95
421-
#> 4 gee - linear_reg .actual 14.3
422-
#> 5 gee - linear_reg .predicted 14.2
423-
#> 6 gee - linear_reg .resid 0.0928
424-
#> 7 gee - linear_reg .actual 15.8
425-
#> 8 gee - linear_reg .predicted 18.5
426-
#> 9 gee - linear_reg .resid -2.67
427-
#> 10 gee - linear_reg .actual 30.4
418+
#> 1 gee - linear_reg .actual 15.5
419+
#> 2 gee - linear_reg .predicted 16.4
420+
#> 3 gee - linear_reg .resid -0.896
421+
#> 4 gee - linear_reg .actual 19.2
422+
#> 5 gee - linear_reg .predicted 19.2
423+
#> 6 gee - linear_reg .resid 0.0385
424+
#> 7 gee - linear_reg .actual 21.5
425+
#> 8 gee - linear_reg .predicted 22.3
426+
#> 9 gee - linear_reg .resid -0.797
427+
#> 10 gee - linear_reg .actual 14.3
428428
#> # ℹ 86 more rows
429429
#>
430430
#> [[3]]
431431
#> # A tibble: 96 × 3
432432
#> .model_type name value
433433
#> <chr> <chr> <dbl>
434-
#> 1 glm - linear_reg .actual 32.4
435-
#> 2 glm - linear_reg .predicted 27.5
436-
#> 3 glm - linear_reg .resid 4.94
437-
#> 4 glm - linear_reg .actual 14.3
438-
#> 5 glm - linear_reg .predicted 14.2
439-
#> 6 glm - linear_reg .resid 0.121
440-
#> 7 glm - linear_reg .actual 15.8
441-
#> 8 glm - linear_reg .predicted 18.5
442-
#> 9 glm - linear_reg .resid -2.71
443-
#> 10 glm - linear_reg .actual 30.4
434+
#> 1 glm - linear_reg .actual 15.5
435+
#> 2 glm - linear_reg .predicted 16.5
436+
#> 3 glm - linear_reg .resid -0.988
437+
#> 4 glm - linear_reg .actual 19.2
438+
#> 5 glm - linear_reg .predicted 19.7
439+
#> 6 glm - linear_reg .resid -0.488
440+
#> 7 glm - linear_reg .actual 21.5
441+
#> 8 glm - linear_reg .predicted 21.6
442+
#> 9 glm - linear_reg .resid -0.127
443+
#> 10 glm - linear_reg .actual 14.3
444444
#> # ℹ 86 more rows
445445
```

man/extract_model_spec.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/extract_regression_residuals.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)