Calculate Loss Functions
loss_cross_entropy(observed, predicted, p_min = 1e-04, na.rm = TRUE)
loss_sum_of_squares(observed, predicted, na.rm = TRUE)
loss_root_mean_square(observed, predicted, na.rm = TRUE)
loss_accuracy(observed, predicted, na.rm = TRUE)
loss_one_minus_accuracy(observed, predicted, cutoff = 0.5, na.rm = TRUE)
get_loss_one_minus_accuracy(cutoff = 0.5, na.rm = TRUE)
loss_one_minus_auc(observed, predicted)
get_loss_default(x)
loss_default(x)
observed scores or labels, these are supplied as explainer specific y
predicted scores, either vector of matrix, these are returned from the model specific predict_function()
for cross entropy, minimal value for probability to make sure that log
will not explode
logical, should missing values be removed?
classification threshold for the accuracy loss functions
either an explainer or type of the model. One of "regression", "classification", "multiclass".
numeric - value of the loss function
# \donttest{
library("ranger")
titanic_ranger_model <- ranger(survived~., data = titanic_imputed, num.trees = 50,
probability = TRUE)
loss_one_minus_auc(titanic_imputed$survived, yhat(titanic_ranger_model, titanic_imputed))
#> [1] 0.1036886
HR_ranger_model_multi <- ranger(status~., data = HR, num.trees = 50, probability = TRUE)
loss_cross_entropy(as.numeric(HR$status), yhat(HR_ranger_model_multi, HR))
#> [1] 2979.306
# }