Skip to content

Commit

Permalink
refactor: gam_mod() -> gen_additive_mod()
Browse files Browse the repository at this point in the history
  • Loading branch information
mdancho84 committed Mar 28, 2021
1 parent 26a93b9 commit c314f24
Show file tree
Hide file tree
Showing 11 changed files with 350 additions and 41 deletions.
8 changes: 4 additions & 4 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Generated by roxygen2: do not edit by hand

S3method(print,gam_mod)
S3method(translate,gam_mod)
S3method(update,gam_mod)
S3method(print,gen_additive_mod)
S3method(translate,gen_additive_mod)
S3method(update,gen_additive_mod)
export("%>%")
export(":=")
export(.data)
Expand All @@ -11,7 +11,7 @@ export(as_name)
export(enquo)
export(enquos)
export(expr)
export(gam_mod)
export(gen_additive_mod)
export(sym)
export(syms)
import(mgcv)
Expand Down
16 changes: 8 additions & 8 deletions R/parsnip-gam_mod.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# gam_mod() - General Interface to Linear GAM Models
# gen_additive_mod() - General Interface to Linear GAM Models
# - backend: gam
# - prediction:
# - mode = "regression" (default) uses
Expand Down Expand Up @@ -82,7 +82,7 @@
#' m750_train <- m750_extended %>% drop_na()
#' m750_future <- m750_extended %>% filter(is.na(value))
#'
#' model_fit_gam <- gam_mod(mode = "regression") %>%
#' model_fit_gam <- gen_additive_mod(mode = "regression") %>%
#' set_engine("gam", family=Gamma(link="log"), method = "REML") %>%
#' fit(value ~ s(date_month, k = 12)
#' + s(date_num)
Expand All @@ -96,7 +96,7 @@
#'
#'
#' @export
gam_mod <- function(mode = "regression",
gen_additive_mod <- function(mode = "regression",
select_features = NULL,
adjust_deg_free = NULL) {

Expand All @@ -106,7 +106,7 @@ gam_mod <- function(mode = "regression",
)

parsnip::new_model_spec(
"gam_mod",
"gen_additive_mod",
args = args,
eng_args = NULL,
mode = mode,
Expand All @@ -117,7 +117,7 @@ gam_mod <- function(mode = "regression",
}

#' @export
print.gam_mod <- function(x, ...) {
print.gen_additive_mod <- function(x, ...) {
cat("GAM Model Specification (", x$mode, ")\n\n", sep = "")
parsnip::model_printer(x, ...)

Expand All @@ -131,7 +131,7 @@ print.gam_mod <- function(x, ...) {

#' @export
#' @importFrom stats update
update.gam_mod <- function(object,
update.gen_additive_mod <- function(object,
select_features = NULL,
adjust_deg_free = NULL,
parameters = NULL,
Expand Down Expand Up @@ -161,7 +161,7 @@ update.gam_mod <- function(object,
}

parsnip::new_model_spec(
"gam_mod",
"gen_additive_mod",
args = object$args,
eng_args = object$eng_args,
mode = object$mode,
Expand All @@ -173,7 +173,7 @@ update.gam_mod <- function(object,

#' @export
#' @importFrom parsnip translate
translate.gam_mod <- function(x, engine = x$engine, ...) {
translate.gen_additive_mod <- function(x, engine = x$engine, ...) {
if (is.null(engine)) {
message("Used `engine = 'gam'` for translation.")
engine <- "gam"
Expand Down
16 changes: 8 additions & 8 deletions R/parsnip-gam_mod_data.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@


make_gam_mod <- function() {
parsnip::set_new_model("gam_mod")
make_gen_additive_mod <- function() {
parsnip::set_new_model("gen_additive_mod")
}

make_gam_mod_mgcv_gam <- function() {
make_gen_additive_mod_mgcv_gam <- function() {

#### REGRESION
model = "gam_mod"
model = "gen_additive_mod"
mode = "regression"
engine = "gam"

Expand All @@ -18,7 +18,7 @@ make_gam_mod_mgcv_gam <- function() {
#Args

parsnip::set_model_arg(
model = "gam_mod",
model = "gen_additive_mod",
eng = "gam",
parsnip = "select_features",
original = "select",
Expand All @@ -27,7 +27,7 @@ make_gam_mod_mgcv_gam <- function() {
)

parsnip::set_model_arg(
model = "gam_mod",
model = "gen_additive_mod",
eng = "gam",
parsnip = "adjust_deg_free",
original = "gamma",
Expand Down Expand Up @@ -118,7 +118,7 @@ make_gam_mod_mgcv_gam <- function() {

#### CLASSIFICATION

model = "gam_mod"
model = "gen_additive_mod"
mode = "classification"
engine = "gam"

Expand Down Expand Up @@ -227,4 +227,4 @@ make_gam_mod_mgcv_gam <- function() {
)
)

}
}
4 changes: 2 additions & 2 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
.onLoad <- function(libname, pkgname) {
# This defines the model database

make_gam_mod()
make_gen_additive_mod()

make_gam_mod_mgcv_gam()
make_gen_additive_mod_mgcv_gam()

}

4 changes: 2 additions & 2 deletions docs/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ pkgdown: 1.6.1
pkgdown_sha: ~
articles:
getting-started: getting-started.html
last_built: 2021-03-26T19:42Z
last_built: 2021-03-28T00:07Z

10 changes: 5 additions & 5 deletions docs/reference/gam_mod.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c314f24

Please sign in to comment.