loss_function()
estimates the loss based on a loss function.
loss_function(
pred,
data.valid,
loss.unit = c("individuals", "L2 units"),
loss.fun = c("MSE", "MAE", "cross-entropy"),
y,
L2.unit
)
Returns a tibble with number of rows equal to the number of loss functions tested (defaults to 4 for cross-entropy, f1, MSE, and msfe). The number of columns is 2 where the first is called measure and contains the names of the loss-functions and the second is called value and contains the loss-function scores.
Predictions of outcome. A numeric vector of outcome predictions.
Test data set. A tibble of data that was not used for prediction.
Loss function unit. A character-valued scalar indicating
whether performance loss should be evaluated at the level of individual
respondents (individuals
) or geographic units (L2 units
).
Default is individuals
.
Loss function. A character-valued scalar indicating whether
prediction loss should be measured by the mean squared error (MSE
)
or the mean absolute error (MAE
). Default is MSE
.
Outcome variable. A character vector containing the column names of the outcome variable.
Geographic unit. A character scalar containing the column name
of the geographic unit in survey
and census
at which outcomes
should be aggregated.