View source: R/deepregression.R
keras_dr | R Documentation |
Compile a Deep Distributional Regression Model
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, ... )
list_pred_param |
list of input-output(-lists) generated from
|
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 |
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 |
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 |
a list with input tensors and output tensors that can be passed
to, e.g., keras_model
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" )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.