keras_dr {deepregression}R Documentation

Compile a Deep Distributional Regression Model

Description

Compile a Deep Distributional Regression Model

Usage

keras_dr(
  list_pred_param,
  weights = NULL,
  optimizer = tf$keras$optimizers$Adam(),
  model_fun = keras_model,
  monitor_metrics = list(),
  from_preds_to_output = from_preds_to_dist,
  loss = from_dist_to_loss(family = list(...)$family, weights = weights),
  additional_penalty = NULL,
  ...
)

Arguments

list_pred_param

list of input-output(-lists) generated from subnetwork_init

weights

vector of positive values; optional (default = 1 for all observations)

optimizer

optimizer used. Per default Adam

model_fun

which function to use for model building (default keras_model)

monitor_metrics

Further metrics to monitor

from_preds_to_output

function taking the list_pred_param outputs and transforms it into a single network output

loss

the model's loss function; per default evaluated based on the arguments family and weights using from_dist_to_loss

additional_penalty

a penalty that is added to the negative log-likelihood; must be a function of model$trainable_weights with suitable subsetting

...

arguments passed to from_preds_to_output

Value

a list with input tensors and output tensors that can be passed to, e.g., keras_model

Examples

set.seed(24)
n <- 500
x <- runif(n) %>% as.matrix()
z <- runif(n) %>% as.matrix()

y <- x - z
data <- data.frame(x = x, z = z, y = y)

# change loss to mse and adapt
# \code{from_preds_to_output} to work
# only on the first output column
mod <- deepregression(
 y = y,
 data = data,
 list_of_formulas = list(loc = ~ 1 + x + z, scale = ~ 1),
 list_of_deep_models = NULL,
 family = "normal",
 from_preds_to_output = function(x, ...) x[[1]],
 loss = "mse"
)



[Package deepregression version 1.0.0 Index]