-
Notifications
You must be signed in to change notification settings - Fork 3
/
LoggerOobRisk.Rd
130 lines (105 loc) · 3.65 KB
/
LoggerOobRisk.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/RcppExports.R
\name{LoggerOobRisk}
\alias{LoggerOobRisk}
\title{Logger class to log the out of bag risk}
\format{\code{\link{S4}} object.}
\description{
This class logs the out of bag risk for a specific loss function. It is
also possible to use custom losses to log performance measures. For details
see the use case or extending compboost vignette.
}
\section{Usage}{
\preformatted{
LoggerOobRisk$new(logger_id, use_as_stopper, used_loss, eps_for_break,
oob_data, oob_response)
}
}
\section{Arguments}{
\describe{
\item{\code{logger_id} [\code{character(1)}]}{
Unique identifier of the logger.
}
\item{\code{use_as_stopper} [\code{logical(1)}]}{
Boolean to indicate if the logger should also be used as stopper.
}
\item{\code{used_loss} [\code{Loss} object]}{
The loss used to calculate the empirical risk by taking the mean of the
returned defined loss within the loss object.
}
\item{\code{eps_for_break} [\code{numeric(1)}]}{
This argument is used if the loss is also used as stopper. If the relative
improvement of the logged inbag risk falls above this boundary the stopper
returns \code{TRUE}.
}
\item{\code{oob_data} [\code{list}]}{
A list which contains data source objects which corresponds to the
source data of each registered factory. The source data objects should
contain the out of bag data. This data is then used to calculate the
prediction in each step.
}
\item{\code{oob_response} [\code{numeric}]}{
Vector which contains the response for the out of bag data given within
the \code{list}.
}
}
}
\section{Details}{
This logger computes the risk for a given new dataset
\eqn{\mathcal{D}_\mathrm{oob} = \{(x^{(i)},\ y^{(i)})\ |\ i \in I_\mathrm{oob}\}}
and stores it into a vector. The OOB risk \eqn{\mathcal{R}_\mathrm{oob}} for
iteration \eqn{m} is calculated by:
\deqn{
\mathcal{R}_\mathrm{oob}^{[m]} = \frac{1}{|\mathcal{D}_\mathrm{oob}|}\sum\limits_{(x,y) \in \mathcal{D}_\mathrm{oob}}
L(y, \hat{f}^{[m]}(x))
}
\strong{Note:}
\itemize{
\item
If \eqn{m=0} than \eqn{\hat{f}} is just the offset.
\item
The implementation to calculate \eqn{\mathcal{R}_\mathrm{emp}^{[m]}} is
done in two steps:
\enumerate{
\item
Calculate vector \code{risk_temp} of losses for every observation for
given response \eqn{y^{(i)}} and prediction \eqn{\hat{f}^{[m]}(x^{(i)})}.
\item
Average over \code{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 \eqn{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.
This class is a wrapper around the pure \code{C++} implementation. To see
the functionality of the \code{C++} class visit
\url{https://schalkdaniel.github.io/compboost/cpp_man/html/classlogger_1_1_oob_risk_logger.html}.
}
\section{Fields}{
This class doesn't contain public fields.
}
\section{Methods}{
\describe{
\item{\code{summarizeLogger()}}{Summarize the logger object.}
}
}
\examples{
# Define data:
X1 = cbind(1:10)
X2 = cbind(10:1)
data_source1 = InMemoryData$new(X1, "x1")
data_source2 = InMemoryData$new(X2, "x2")
oob_list = list(data_source1, data_source2)
set.seed(123)
y_oob = rnorm(10)
# Used loss:
log_bin = LossBinomial$new()
# Define response object of oob data:
oob_response = ResponseRegr$new("oob_response", as.matrix(y_oob))
# Define logger:
log_oob_risk = LoggerOobRisk$new("oob", FALSE, log_bin, 0.05, oob_list, oob_response)
# Summarize logger:
log_oob_risk$summarizeLogger()
}