Fit a CANN (combined actuarial neural network)
cann_fit.RdWüthrich and Merz's Combined Actuarial Neural Network: the offset (a
GLM's linear predictor, with offset(...) terms or offset) plus a
feed-forward network of the formula's design columns,
eta = offset + NN(x). The network's output layer starts at zero, so
training starts exactly at the GLM and learns only what it misses.
Training minimizes the family's weighted deviance by Adam on
mini-batches, on the CPU in double precision, and is reproducible from
seed. Columns are standardized internally.
Usage
cann_fit(
formula,
data,
family = "poisson",
link = NULL,
hidden = c(16, 8),
epochs = 200,
batch_size = 64,
learning_rate = 0.001,
seed = 0,
validation_share = NULL,
patience = 10,
offset = NULL,
weights = NULL,
power = NULL
)Arguments
- formula
A model formula;
offset(...)terms are honoured.- data
A data frame.
- family
"poisson","gamma","tweedie"(needspower) or"gaussian".- link
NULLfor log (identity for the Gaussian), the only links the networks support.Widths of the hidden ReLU layers.
- epochs, batch_size, learning_rate
Adam's settings.
- seed
Seeds the initial weights and the mini-batch order.
NULL, or a share of rows held out for early stopping: the mean deviance on them is scored after each epoch and the best epoch kept.- patience
With early stopping, epochs without improvement before stopping.
- offset
Optional offset added to any
offset()terms.- weights
Optional prior weights.
- power
Tweedie power in
(1, 2).
Value
A cann_model with properties fitted, dispersion,
best_epoch (NA without early stopping) and validation_history.
Use stats::predict(), predict_distribution() and
network_correction(). A fitted network has no artifact yet, so
save_model() does not take it.