Learn R Programming

deepregression (version 2.2.0)

plot.deepregression: Generic functions for deepregression models

Description

Generic functions for deepregression models

Predict based on a deepregression object

Function to extract fitted distribution

Fit a deepregression model (pendant to fit for keras)

Extract layer weights / coefficients from model

Print function for deepregression model

Cross-validation for deepgression objects

mean of model fit

Standard deviation of fit distribution

Calculate the distribution quantiles

Usage

# S3 method for deepregression
plot(
  x,
  which = NULL,
  which_param = 1,
  only_data = FALSE,
  grid_length = 40,
  main_multiple = NULL,
  type = "b",
  get_weight_fun = get_weight_by_name,
  ...
)

# S3 method for deepregression predict( object, newdata = NULL, batch_size = NULL, apply_fun = tfd_mean, convert_fun = as.matrix, ... )

# S3 method for deepregression fitted(object, apply_fun = tfd_mean, ...)

# S3 method for deepregression fit( object, batch_size = 32, epochs = 10, early_stopping = FALSE, early_stopping_metric = "val_loss", verbose = TRUE, view_metrics = FALSE, patience = 20, save_weights = FALSE, validation_data = NULL, validation_split = ifelse(is.null(validation_data), 0.1, 0), callbacks = list(), na_handler = na_omit_list, ... )

# S3 method for deepregression coef(object, which_param = 1, type = NULL, ...)

# S3 method for deepregression print(x, ...)

# S3 method for deepregression cv( x, verbose = FALSE, patience = 20, plot = TRUE, print_folds = TRUE, cv_folds = 5, stop_if_nan = TRUE, mylapply = lapply, save_weights = FALSE, callbacks = list(), save_fun = NULL, ... )

# S3 method for deepregression mean(x, data = NULL, ...)

# S3 method for deepregression stddev(x, data = NULL, ...)

# S3 method for deepregression quant(x, data = NULL, probs, ...)

Value

Returns an object drCV, a list, one list element for each fold containing the model fit and the weighthistory.

Arguments

x

a deepregression object

which

character vector or number(s) identifying the effect to plot; default plots all effects

which_param

integer, indicating for which distribution parameter coefficients should be returned (default is first parameter)

only_data

logical, if TRUE, only the data for plotting is returned

grid_length

the length of an equidistant grid at which a two-dimensional function is evaluated for plotting.

main_multiple

vector of strings; plot main titles if multiple plots are selected

type

either NULL (all types of coefficients are returned), "linear" for linear coefficients or "smooth" for coefficients of smooth terms

get_weight_fun

function to extract weight from model given x, a name and param_nr

...

arguments passed to the predict function

object

a deepregression model

newdata

optional new data, either data.frame or list

batch_size

integer, the batch size used for mini-batch training

apply_fun

function applied to fitted distribution, per default tfd_mean

convert_fun

how should the resulting tensor be converted, per default as.matrix

epochs

integer, the number of epochs to fit the model

early_stopping

logical, whether early stopping should be user.

early_stopping_metric

character, based on which metric should early stopping be trigged (default: "val_loss")

verbose

whether to print training in each fold

view_metrics

logical, whether to trigger the Viewer in RStudio / Browser.

patience

number of patience for early stopping

save_weights

logical, whether to save weights in each epoch.

validation_data

optional specified validation data

validation_split

float in [0,1] defining the amount of data used for validation

callbacks

a list of callbacks used for fitting

na_handler

function to deal with NAs

plot

whether to plot the resulting losses in each fold

print_folds

whether to print the current fold

cv_folds

an integer; can also be a list of lists with train and test data sets per fold

stop_if_nan

logical; whether to stop CV if NaN values occur

mylapply

lapply function to be used; defaults to lapply

save_fun

function applied to the model in each fold to be stored in the final result

data

either NULL or a new data set

probs

the quantile value(s)