Skip to content

Commit 8331260

Browse files
authored
Merge pull request #350 from tidymodels/glance
glance method for model fits
2 parents f333aba + a46ca92 commit 8331260

File tree

13 files changed

+67
-20
lines changed

13 files changed

+67
-20
lines changed

.github/workflows/R-CMD-check.yaml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ jobs:
1515
fail-fast: false
1616
matrix:
1717
config:
18-
- {os: macOS-latest, r: 'devel'}
1918
- {os: macOS-latest, r: 'release'}
2019
- {os: windows-latest, r: 'release'}
2120
- {os: windows-latest, r: '3.6'}
21+
- {os: ubuntu-16.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
2222
- {os: ubuntu-16.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
2323
- {os: ubuntu-16.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
2424
- {os: ubuntu-16.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
@@ -54,12 +54,11 @@ jobs:
5454

5555
- name: Install system dependencies
5656
if: runner.os == 'Linux'
57-
env:
58-
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
5957
run: |
60-
Rscript -e "remotes::install_github('r-hub/sysreqs')"
61-
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
62-
sudo -s eval "$sysreqs"
58+
while read -r cmd
59+
do
60+
eval sudo $cmd
61+
done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "16.04"), sep = "\n")')
6362
6463
- name: Install dependencies
6564
run: |
@@ -102,7 +101,7 @@ jobs:
102101

103102
- name: Upload check results
104103
if: failure()
105-
uses: actions/upload-artifact@master
104+
uses: actions/upload-artifact@main
106105
with:
107106
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
108107
path: check

.github/workflows/pkgdown.yaml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,15 @@ jobs:
3232

3333
- name: Install dependencies
3434
run: |
35-
install.packages("remotes")
3635
remotes::install_deps(dependencies = TRUE)
37-
remotes::install_dev("pkgdown")
38-
remotes::install_github("tidyverse/tidytemplate")
39-
remotes::install_cran("tidymodels")
40-
remotes::install_cran("C50")
41-
remotes::install_cran("modeldata")
36+
install.packages("pkgdown")
4237
shell: Rscript {0}
4338

4439
- name: Install package
4540
run: R CMD INSTALL .
4641

4742
- name: Deploy package
48-
run: pkgdown::deploy_to_branch(new_process = FALSE)
49-
shell: Rscript {0}
43+
run: |
44+
git config --local user.email "actions@github.com"
45+
git config --local user.name "GitHub Actions"
46+
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)'

.github/workflows/pr-commands.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ jobs:
2121
run: Rscript -e 'roxygen2::roxygenise()'
2222
- name: commit
2323
run: |
24+
git config --local user.email "actions@github.com"
25+
git config --local user.name "GitHub Actions"
2426
git add man/\* NAMESPACE
2527
git commit -m 'Document'
2628
- uses: r-lib/actions/pr-push@master
@@ -44,6 +46,8 @@ jobs:
4446
run: Rscript -e 'styler::style_pkg()'
4547
- name: commit
4648
run: |
49+
git config --local user.email "actions@github.com"
50+
git config --local user.name "GitHub Actions"
4751
git add \*.R
4852
git commit -m 'Style'
4953
- uses: r-lib/actions/pr-push@master

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Imports:
3131
prettyunits,
3232
vctrs (>= 0.2.0)
3333
Roxygen: list(markdown = TRUE)
34-
RoxygenNote: 7.1.0.9000
34+
RoxygenNote: 7.1.1
3535
Suggests:
3636
testthat,
3737
knitr,

NAMESPACE

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
S3method(fit,model_spec)
44
S3method(fit_xy,model_spec)
5+
S3method(glance,model_fit)
56
S3method(has_multi_predict,default)
67
S3method(has_multi_predict,model_fit)
78
S3method(has_multi_predict,workflow)
@@ -121,6 +122,7 @@ export(get_fit)
121122
export(get_from_env)
122123
export(get_model_env)
123124
export(get_pred_type)
125+
export(glance)
124126
export(has_multi_predict)
125127
export(is_varying)
126128
export(keras_mlp)
@@ -198,6 +200,7 @@ importFrom(dplyr,tally)
198200
importFrom(dplyr,vars)
199201
importFrom(generics,fit)
200202
importFrom(generics,fit_xy)
203+
importFrom(generics,glance)
201204
importFrom(generics,tidy)
202205
importFrom(generics,varying_args)
203206
importFrom(glue,glue_collapse)

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# parsnip (development version)
22

3+
* A `glance()` method for `model_fit` objects was added (#325)
4+
35
* Specific `tidy()` methods for `glmnet` models fit via `parsnip` were created so that the coefficients for the specific fitted `parsnip` model are returned.
46

57
# parsnip 0.1.2

R/reexports.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,8 @@ generics::fit_xy
1414
#' @importFrom generics tidy
1515
#' @export
1616
generics::tidy
17+
18+
19+
#' @importFrom generics glance
20+
#' @export
21+
generics::glance

R/tidy.R

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,14 @@
77
#' @return a tibble
88
#' @export
99
tidy.model_fit <- function(x, ...) generics::tidy(x$fit, ...)
10+
11+
12+
#' Construct a single row summary "glance" of a model, fit, or other object
13+
#'
14+
#' This method glances the model in a parsnip model object, if it exists.
15+
#'
16+
#' @inheritParams generics::glance
17+
#'
18+
#' @return a tibble
19+
#' @export
20+
glance.model_fit <- function(x, ...) generics::glance(x$fit, ...)

R/zzz.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
s3_register("broom::tidy", "_lognet")
88
s3_register("broom::tidy", "_multnet")
99
s3_register("broom::tidy", "_fishnet")
10+
s3_register("broom::glance", "model_fit")
1011
}
1112

1213

README.Rmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ knitr::opts_chunk$set(
2121
[![CRAN status](https://www.r-pkg.org/badges/version/parsnip)](https://CRAN.R-project.org/package=parsnip)
2222
[![Downloads](http://cranlogs.r-pkg.org/badges/parsnip)](https://cran.rstudio.com/package=parsnip)
2323
[![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing)
24+
[![R build status](https://github.com/tidymodels/parsnip/workflows/R-CMD-check/badge.svg)](https://github.com/tidymodels/parsnip/actions)
2425
<!-- badges: end -->
2526

2627
## Introduction
@@ -112,6 +113,7 @@ rand_forest(mtry = 10, trees = 2000) %>%
112113
Either one of these model specifications can be fit in the same way:
113114

114115
```{r}
116+
set.seed(192)
115117
rand_forest(mtry = 10, trees = 2000) %>%
116118
set_engine("ranger", importance = "impurity") %>%
117119
set_mode("regression") %>%

0 commit comments

Comments
 (0)