From 8616fdb43771a1692aef8bfac69dd8aecba890cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=98topepo=E2=80=99?= <‘mxkuhn@gmail.com’> Date: Fri, 12 Jan 2024 13:57:09 -0500 Subject: [PATCH 1/2] export and document case_weights_allowed --- DESCRIPTION | 2 +- NAMESPACE | 1 + R/case_weights.R | 11 +++++++++++ man/case_weights_allowed.Rd | 22 ++++++++++++++++++++++ man/glmnet-details.Rd | 4 ++-- 5 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 man/case_weights_allowed.Rd diff --git a/DESCRIPTION b/DESCRIPTION index 37dff5bd9..d7ca644f7 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -76,4 +76,4 @@ Config/testthat/edition: 3 Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.2.3.9000 +RoxygenNote: 7.2.3 diff --git a/NAMESPACE b/NAMESPACE index 9562ecdc2..2465d298d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -178,6 +178,7 @@ export(bag_tree) export(bart) export(bartMachine_interval_calc) export(boost_tree) +export(case_weights_allowed) export(cforest_train) export(check_empty_ellipse) export(check_final_param) diff --git a/R/case_weights.R b/R/case_weights.R index 8c5c0a790..5709286bb 100644 --- a/R/case_weights.R +++ b/R/case_weights.R @@ -67,6 +67,17 @@ patch_formula_environment_with_case_weights <- function(formula, # ------------------------------------------------------------------------------ +#' Determine if case weights are used +#' +#' Not all modeling engines can incorporate case weights into their +#' calculations. This function can determine whether they can be used. +#' +#' @param spec A parsnip model specification. +#' @return A single logical. +#' @examples +#' case_weights_allowed(linear_reg()) +#' case_weights_allowed(linear_reg(engine = "keras")) +#' @export case_weights_allowed <- function(spec) { mod_type <- class(spec)[1] mod_eng <- spec$engine diff --git a/man/case_weights_allowed.Rd b/man/case_weights_allowed.Rd new file mode 100644 index 000000000..1c070b6b5 --- /dev/null +++ b/man/case_weights_allowed.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/case_weights.R +\name{case_weights_allowed} +\alias{case_weights_allowed} +\title{Determine if case weights are used} +\usage{ +case_weights_allowed(spec) +} +\arguments{ +\item{spec}{A parsnip model specification.} +} +\value{ +A single logical. +} +\description{ +Not all modeling engines can incorporate case weights into their +calculations. This function can determine whether they can be used. +} +\examples{ +case_weights_allowed(linear_reg()) +case_weights_allowed(linear_reg(engine = "keras")) +} diff --git a/man/glmnet-details.Rd b/man/glmnet-details.Rd index 4fd6a4f65..9a1c6c6fa 100644 --- a/man/glmnet-details.Rd +++ b/man/glmnet-details.Rd @@ -189,7 +189,7 @@ originally requested: ## 4 hp -0.0101 1 ## 5 drat 0 1 ## 6 wt -2.59 1 -## # … with 5 more rows +## # ℹ 5 more rows }\if{html}{\out{}} Note that there is a \code{tidy()} method for \code{glmnet} objects in the \code{broom} @@ -210,7 +210,7 @@ all_tidy_coefs ## 4 (Intercept) 4 24.7 3.89 0.347 ## 5 (Intercept) 5 26.0 3.55 0.429 ## 6 (Intercept) 6 27.2 3.23 0.497 -## # … with 634 more rows +## # ℹ 634 more rows }\if{html}{\out{}} \if{html}{\out{
}}\preformatted{length(unique(all_tidy_coefs$lambda)) From eb25efd924ac54ec93c95068a05996cfe11ad8b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=98topepo=E2=80=99?= <‘mxkuhn@gmail.com’> Date: Fri, 12 Jan 2024 14:07:41 -0500 Subject: [PATCH 2/2] missing pkgdown entry --- _pkgdown.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/_pkgdown.yml b/_pkgdown.yml index 357aac829..78e5d56cc 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -71,6 +71,7 @@ reference: - add_rowindex - augment.model_fit - case_weights + - case_weights_allowed - descriptors - extract-parsnip - fit.model_spec