fit_ontram | R Documentation |
Function for estimating the model
fit_ontram(
model,
history = FALSE,
x_train = NULL,
y_train,
img_train = NULL,
x_test = NULL,
y_test = NULL,
img_test = NULL,
verbose = FALSE,
early_stopping = FALSE,
patience = 1,
min_delta = 0,
stop_train = FALSE,
save_best = FALSE,
filepath = NULL,
warm_start = FALSE,
weights = NULL,
eval_batchwise = TRUE,
img_augmentation = FALSE,
aug_params = list(horizontal_flip = TRUE, vertical_flip = TRUE, zoom_range = 0.2,
rotation_range = 30, width_shift_range = 0.15, height_shift_range = 0.15, fill_mode =
"nearest")
)
model |
an object of class |
history |
logical. If TRUE train and test loss are returned as a list. |
x_train, y_train, img_train |
data used for training the model. |
x_test, y_test, img_test |
data used for evaluating the model. |
verbose |
logical. Whether to print current training loss when |
early_stopping |
logical. Whether to use early stopping (requires |
patience |
number of epochs with no improvement after which training will be stopped. |
min_delta |
minimum increase in test loss considered as no improvement. |
stop_train |
logical. Whether model should be trained for all epochs. |
save_best |
logical. Whether best model should be saved as HDF file. |
filepath |
path where to save best model if |
warm_start |
logical. Whether initial weights should be non-random. |
weights |
output output of |
eval_batchwise |
logical. |
img_augmentation |
logical. Whether to augment training images. |
aug_params |
list with arguments used for |
data("wine", package = "ordinal")
fml <- rating ~ temp + contact
x_train <- model.matrix(fml, data = wine)[, -1L]
y_train <- model.matrix(~ 0 + rating, data = wine)
x_valid <- x_train[1:20,]
y_valid <- y_train[1:20,]
mo1 <- ontram_polr(x_dim = ncol(x_train), y_dim = ncol(y_train),
method = "logit", n_batches = 10, epochs = 50)
mo1hist <- fit_ontram(mo1, x_train = x_train, y_train = y_train, history = TRUE,
x_test = x_valid, y_test = y_valid)
plot(mo1hist)
mbl <- keras_model_sequential() %>%
layer_dense(units = 16, activation = "relu", input_shape = ncol(x_train)) %>%
layer_dense(units = 16, activation = "relu") %>%
layer_dense(units = 16, activation = "relu") %>%
layer_dense(units = 16, activation = "relu") %>%
layer_dense(units = ncol(y_train) - 1L)
mo2 <- ontram(mod_bl = mbl, mod_sh = NULL, mod_im = NULL, y_dim = ncol(y_train),
x_dim = NULL, img_dim = NULL, method = "logit",
epochs = 50, response_varying = TRUE)
mo2hist <- fit_ontram(mo2, x_train = NULL, y_train = y_train, img_train = x_train,
x_test = NULL, y_test = y_valid, img_test = x_valid,
history = TRUE, early_stopping = TRUE, stop_train = FALSE)
plot(mo2hist, add_best = TRUE, ylim = c(0, 2.5))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.