dependence: Partial-Dependence Effects

View source: R/dependence.R

dependenceR Documentation

Partial-Dependence Effects

Description

Generate data for partial dependence plots.

Usage

dependence(object, ...)

## S3 method for class 'nested'
dependence(
  object,
  x = NULL,
  cond = NULL,
  alpha = NULL,
  lambda = NULL,
  n_pred = NULL,
  metric = "auto",
  oneSE = TRUE,
  x_lab = NULL,
  y_lab = NULL,
  ...,
  parallel_type = NULL,
  n_cores = NULL,
  cl = NULL
)

## S3 method for class 'beset'
dependence(
  object,
  x = NULL,
  cond = NULL,
  alpha = NULL,
  lambda = NULL,
  n_pred = NULL,
  metric = "auto",
  oneSE = TRUE,
  x_lab = NULL,
  y_lab = NULL,
  ...,
  parallel_type = NULL,
  n_cores = NULL,
  cl = NULL
)

## S3 method for class 'beset_rf'
dependence(
  object,
  x = NULL,
  cond = NULL,
  x_lab = NULL,
  y_lab = NULL,
  ...,
  parallel_type = NULL,
  n_cores = NULL,
  cl = NULL
)

## S3 method for class 'part_depend'
plot(x, order = "delta", p_max = 16, ...)

Arguments

object

A "beset" model object for which partial dependence plots are desired.

...

Additional arguments affecting the plots produced.

x

(Optional) character vector giving name(s) of predictors for which partial dependence effects should be estimated. If omitted, partial dependence effects will be estimated for all predictors in the model.

cond

(Optional) named list of the values to use for one or more predictors when estimating the partial effect of the predictor(s) named in x. Any predictor omitted from this list will be assigned the mean observed value for continuous variables, or the modal level for factors.

alpha

Value of the elastic-net mixing parameter alpha at which predictions are required. Must be a value of alpha that was tried during training. If omitted, cross-validated optimal or 1SE-from-optimal alpha will be used, depending on oneSE argument.

lambda

Value of the elastic-net penalty parameter lambda at which predictions are required. If omitted, cross-validated optimal or 1SE-from-optimal lambda will be used, depending on oneSE argument.

n_pred

(Optional) integer number of predictors that the best model should contain. If specified, all other arguments are ignored.

metric

Character string giving prediction metric on which to base model selection. Can be one of "auc" for area under the (ROC) curve (only available for binomial family), "mae" for mean absolute error (not available for binomial family), "mae" for mean absolute error, "mce" for mean cross entropy, or "mse" for mean squared error. Default is "auto" which plots MSE for Gaussian-family models and MCE for all other families.

oneSE

Logical indicating whether or not to use the "one standard error" rule. If TRUE (default) the simplest model within one standard error of the optimal model is returned. If FALSE the model with the optimal cross-validation performance is returned.

x_lab

(Optional) character vector giving replacement labels for x. Labels should be listed in the same order as the predictor names in x, or, if x is omitted, the same column order as the predictors in the model data frame. If omitted, plots will be labeled with the names of the predictors as they appear in the model object.

y_lab

(Optional) character string giving replacement label for the response variable in the model. If omitted, plots will be labeled with the name of the response as it appears in the model object.

parallel_type

(Optional) character string indicating the type of parallel operation to be used, either "fork" or "sock". If omitted and n_cores > 1, the default is "sock" for Windows and otherwise either "fork" or "sock" depending on which process is being run.

n_cores

Integer value indicating the number of workers to run in parallel during subset search and cross-validation. By default, this will be set to one fewer than the maximum number of physical cores you have available, as indicated by detectCores. Set to 1 to disable parallel processing.

cl

(Optional) parallel or snow cluster for use if parallel_type = "sock". If not supplied, a cluster on the local machine is automatically created.

order

If plotting a grid, order in which partial dependence plots should appear. Options are "delta" (default), which arranges plots based on the magnitude of change in y over the range of each x, and "import", which arranges plots based on the variable importance scores returned by the object's importance method.

p_max

Maximum number of partial dependence effects to plot. Default is 16, resulting in a 4 X 4 grid.


jashu/beset documentation built on April 20, 2023, 5:28 a.m.