Visualization of Loss Functions
loss_functions.Rmd
Loss Functions
The VisualizerLossFunction
class visualizes loss
functions. Loss functions are wrapped in LossFunction
objects. The package includes a few predefined loss functions that are
used for classification and regression.
as.data.table(dict_loss)
#> Key: <key>
#> key label properties
#> <char> <char> <list>
#> 1: cross-entropy Cross-Entropy classif
#> 2: hinge Hinge Loss classif
#> 3: huber Huber Loss regr
#> 4: l1_ae L1 Absolute Error regr
#> 5: l2_se L2 Squared Error regr
#> 6: log-cosh Log-Cosh Loss regr
To get a loss function from the dictionary, use the
lss()
function We retrieve the hinge loss function for
classification.
loss_function = lss("hinge")
Visualization
To visualize the loss function, use the as_visualizer()
function. The y_pred
arguments contains
and y_true
the true value
.
vis = as_visualizer(loss_function, y_pred = seq(-4, 4), y_true = 1)
Use the plot()
method to plot the loss function.
vis$plot()