lloss: Calculate the Log Lossfor predicted probabilities against a...

View source: R/lloss.R

llossR Documentation

Calculate the Log Lossfor predicted probabilities against a binary outcome.

Description

Calculate the Log Lossfor predicted probabilities against a binary outcome.

Usage

lloss(preds, obs, eps = 1e-15)

Arguments

preds

A vector of predicted probabilities.

obs

A vector containing the observed binary outcomes (0 or 1).

eps

Epsilon representing the tolerance of the numeric result, used in order to avoid zero errors.

Value

The Log Loss given by

logloss = y_i(\log \hat y_i) + (1-y_i)\log(1-\hat y_i)

Examples

# Generate some predictions
predictions <- runif(1000)
# Generate some binary outcomes
observations <- sample(0:1, size = 1000, replace = TRUE)
# Calculate the Brier Score
lloss(predictions, observations)

gweissman/gmish documentation built on Feb. 16, 2025, 8:38 a.m.