Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ binary_log_loss() [4/6]

var stan::math::binary_log_loss ( int  y,
const var y_hat 
)
inline

The log loss function for variables (stan).

See binary_log_loss() for the double-based version.

The derivative with respect to the variable \(\hat{y}\) is

\(\frac{d}{d\hat{y}} \mbox{logloss}(1, \hat{y}) = - \frac{1}{\hat{y}}\), and

\(\frac{d}{d\hat{y}} \mbox{logloss}(0, \hat{y}) = \frac{1}{1 - \hat{y}}\).

\[ \mbox{binary\_log\_loss}(y, \hat{y}) = \begin{cases} y \log \hat{y} + (1 - y) \log (1 - \hat{y}) & \mbox{if } 0\leq \hat{y}\leq 1, y\in\{ 0, 1 \}\\[6pt] \textrm{NaN} & \mbox{if } \hat{y} = \textrm{NaN} \end{cases} \]

\[ \frac{\partial\, \mbox{binary\_log\_loss}(y, \hat{y})}{\partial \hat{y}} = \begin{cases} \frac{y}{\hat{y}}-\frac{1-y}{1-\hat{y}} & \mbox{if } 0\leq \hat{y}\leq 1, y\in\{ 0, 1 \}\\[6pt] \textrm{NaN} & \mbox{if } \hat{y} = \textrm{NaN} \end{cases} \]

Parameters
yReference value.
y_hatResponse variable.
Returns
Log loss of response versus reference value.

Definition at line 46 of file binary_log_loss.hpp.