This class logs the train risk for a specific loss function.
Format
S4 object.
Arguments
- logger_id
(
character(1)
)
Identifier of the logger.- use_as_stopper
(
logical(1)
)
Boolean to indicate if the logger should also be used as a stopper.- loss
(LossQuadratic | LossBinomial | LossHuber | LossAbsolute | LossQuantile)
An initializedS4
loss object (requires to callLoss*$new(...)
). See the respective help page for further information.- eps_for_break
(
numeric(1)
)
This argument becomes active if the loss is also used as stopper. If the relative improvement of the logged inbag risk falls above this boundary the stopper returnsTRUE
.- patience
(
integer(1)
)
The number of consecutive conditions that must be true to return a stop signal.
Usage
LoggerInbagRisk$new(logger_id, use_as_stopper, loss, eps_for_break, patience)
Details
This logger computes the risk for the training data \(\mathcal{D} = \{(x^{(i)},\ y^{(i)})\ |\ i \in \{1, \dots, n\}\}\) and stores it into a vector. The empirical risk \(\mathcal{R}_\mathrm{emp}\) for iteration \(m\) is calculated by: $$ \mathcal{R}_\mathrm{emp}^{[m]} = \frac{1}{n}\sum\limits_{i = 1}^n L(y^{(i)}, \hat{f}^{[m]}(x^{(i)})) $$ Note:
If \(m=0\) than \(\hat{f}\) is just the offset.
The implementation to calculate \(\mathcal{R}_\mathrm{emp}^{[m]}\) is done in two steps:
Calculate vector
risk_temp
of losses for every observation for given response \(y^{(i)}\) and prediction \(\hat{f}^{[m]}(x^{(i)})\).Average over
risk_temp
.
This procedure ensures, that it is possible to e.g. use the AUC or any arbitrary performance measure for risk logging. This gives just one value for
risk_temp
and therefore the average equals the loss function. If this is just a value (like for the AUC) then the value is returned.
Examples
# Used loss:
log_bin = LossBinomial$new()
# Define logger:
log_inbag_risk = LoggerInbagRisk$new("inbag", FALSE, log_bin, 0.05, 5)
# Summarize logger:
log_inbag_risk$summarizeLogger()
#> Inbag risk logger:
#> - Use logger as stopper: 0