templates: Functions to create boilerplate code for specific models

use_glmnetR Documentation

Functions to create boilerplate code for specific models

Description

These functions make suggestions for code when using a few common models. They print out code to the console that could be considered minimal syntax for their respective techniques. Each creates a prototype recipe and workflow object that can be edited or updated as the data require.

Usage

use_glmnet(
  formula,
  data,
  prefix = "glmnet",
  verbose = FALSE,
  tune = TRUE,
  colors = TRUE,
  clipboard = FALSE
)

use_xgboost(
  formula,
  data,
  prefix = "xgboost",
  verbose = FALSE,
  tune = TRUE,
  colors = TRUE,
  clipboard = FALSE
)

use_kknn(
  formula,
  data,
  prefix = "kknn",
  verbose = FALSE,
  tune = TRUE,
  colors = TRUE,
  clipboard = FALSE
)

use_ranger(
  formula,
  data,
  prefix = "ranger",
  verbose = FALSE,
  tune = TRUE,
  colors = TRUE,
  clipboard = FALSE
)

use_earth(
  formula,
  data,
  prefix = "earth",
  verbose = FALSE,
  tune = TRUE,
  colors = TRUE,
  clipboard = FALSE
)

use_cubist(
  formula,
  data,
  prefix = "cubist",
  verbose = FALSE,
  tune = TRUE,
  colors = TRUE,
  clipboard = FALSE
)

use_kernlab_svm_rbf(
  formula,
  data,
  prefix = "kernlab",
  verbose = FALSE,
  tune = TRUE,
  colors = TRUE,
  clipboard = FALSE
)

use_kernlab_svm_poly(
  formula,
  data,
  prefix = "kernlab",
  verbose = FALSE,
  tune = TRUE,
  colors = TRUE,
  clipboard = FALSE
)

use_C5.0(
  formula,
  data,
  prefix = "C50",
  verbose = FALSE,
  tune = TRUE,
  colors = TRUE,
  clipboard = FALSE
)

use_nnet(
  formula,
  data,
  prefix = "nnet",
  verbose = FALSE,
  tune = TRUE,
  colors = TRUE,
  clipboard = FALSE
)

use_rpart(
  formula,
  data,
  prefix = "rpart",
  verbose = FALSE,
  tune = TRUE,
  colors = TRUE,
  clipboard = FALSE
)

use_bag_tree_rpart(
  formula,
  data,
  prefix = "rpart",
  verbose = FALSE,
  tune = TRUE,
  colors = TRUE,
  clipboard = FALSE
)

use_mgcv(
  formula,
  data,
  prefix = "mgcv",
  verbose = FALSE,
  tune = TRUE,
  colors = TRUE,
  clipboard = FALSE
)

use_dbarts(
  formula,
  data,
  prefix = "dbarts",
  verbose = FALSE,
  tune = TRUE,
  colors = TRUE,
  clipboard = FALSE
)

use_mixOmics(
  formula,
  data,
  prefix = "mixOmics",
  verbose = FALSE,
  tune = TRUE,
  colors = TRUE,
  clipboard = FALSE
)

use_xrf(
  formula,
  data,
  prefix = "xrf",
  verbose = FALSE,
  tune = TRUE,
  colors = TRUE,
  clipboard = FALSE
)

Arguments

formula

A simple model formula with no in-line functions. This will be used to template the recipe object as well as determining which outcome and predictor columns will be used.

data

A data frame with the columns used in the analysis.

prefix

A single character string to use as a prefix for the resulting objects.

verbose

A single logical that determined whether comments are added to the printed code explaining why certain lines are used.

tune

A single logical that controls if code for model tuning should be printed.

colors

A single logical for coloring warnings and code snippets that require the users attention (ignored when colors = FALSE)

clipboard

A single logical for whether the code output should be sent to the clip board or printed in the console.

Details

Based on the columns in data, certain recipe steps printed. For example, if a model requires that qualitative predictors be converted to numeric (say, using dummy variables) then an additional step_dummy() is added. Otherwise that recipe step is not included in the output.

The syntax is opinionated and should not be considered the exact answer for every data analysis. It has reasonable defaults.

Value

Invisible NULL but code is printed to the console.

Examples

library(modeldata)
data(ad_data)
use_glmnet(Class ~ ., data = ad_data)

data(Sacramento)
use_glmnet(price ~ ., data = Sacramento, verbose = TRUE, prefix = "sac_homes")

tidymodels/usemodels documentation built on March 27, 2023, 1:21 a.m.