methodDR: Generic functions for deepregression models

plot.deepregressionR Documentation

Generic functions for deepregression models

Description

Generic functions for deepregression models

Function to prepare data for deepregression use

Predict based on a deepregression object

Predict based on a deeptrafo object

Function to extract fitted distribution

Fit a deepregression model

Fit a custom deepregression models

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 class 'deepregression'
plot(
  x,
  which = NULL,
  which_param = 1,
  plot = TRUE,
  use_posterior = FALSE,
  grid_length = 40,
  ...
)

prepare_data(x, data, pred = TRUE)

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

## S3 method for class 'deeptrafo'
predict(object, newdata = NULL, which = NULL, cast_float = FALSE, ...)

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

## S3 method for class 'deepregression'
fit(
  x,
  early_stopping = FALSE,
  verbose = TRUE,
  view_metrics = FALSE,
  patience = 20,
  save_weights = FALSE,
  auc_callback = FALSE,
  validation_data = NULL,
  callbacks = list(),
  convertfun = function(x) tf$constant(x, dtype = "float32"),
  ...
)

## S3 method for class 'deepregression'
coef(object, variational = FALSE, params = NULL, type = NULL, ...)

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

cv(
  x,
  verbose = FALSE,
  patience = 20,
  plot = TRUE,
  print_folds = TRUE,
  cv_folds = NULL,
  stop_if_nan = TRUE,
  mylapply = lapply,
  save_weights = FALSE,
  callbacks = list(),
  ...
)

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

## S3 method for class 'deepregression'
sd(x, data = NULL, ...)

## S3 method for class 'deepregression'
quantile(x, data = NULL, probs, ...)

Arguments

x

a deepregression object

which

which effect to plot, default selects all.

which_param

integer of length 1. Corresponds to the distribution parameter for which the effects should be plotted.

plot

whether to plot the resulting losses in each fold

use_posterior

logical; if TRUE it is assumed that the strucuted_nonlinear layer has stored a list of length two as weights, where the first entry is a vector of mean and sd for each network weight. The sd is transformed using the exp function. The plot then shows the mean curve +- 2 times sd.

grid_length

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

...

arguments passed to the predict function

data

either NULL or a new data set

pred

logical, where the data corresponds to a prediction task

object

a deepregression model

newdata

optional new data, either data.frame or list

batch_size

batch_size for generator (image use cases)

apply_fun

function applied to fitted distribution, per default tfd_mean

convert_fun

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

dtype

string for conversion

early_stopping

logical, whether early stopping should be user.

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.

auc_callback

logical, whether to use a callback for AUC

validation_data

optional specified validation data

callbacks

a list of callbacks used for fitting

convertfun

function to convert R into Tensor object

variational

logical, if TRUE, the function takes into account that coefficients have both a mean and a variance

params

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

type

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

print_folds

whether to print the current fold

cv_folds

see deepregression

stop_if_nan

logical; whether to stop CV if NaN values occur

mylapply

lapply function to be used; defaults to lapply

probs

the quantile value(s)

train

function taking the keras model, inputs and outputs as an updates the model

epochs

integer; the number of epochs to train

print_fun

function to print metrics

Value

returns a function with two parameters: the actual response and type in c('trafo', 'pdf', 'cdf', 'interaction') determining the returned value

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


davidruegamer/deepregression documentation built on May 30, 2022, 6:21 p.m.