loss_function: Estimates loss value.

Description Usage Arguments Value

View source: R/utils.R

Description

loss_function() estimates the loss based on a loss function.

Usage

1
2
3
4
5
6
7
8
loss_function(
  pred,
  data.valid,
  loss.unit = c("individuals", "L2 units"),
  loss.fun = c("MSE", "MAE", "cross-entropy"),
  y,
  L2.unit
)

Arguments

pred

Predictions of outcome. A numeric vector of outcome predictions.

data.valid

Test data set. A tibble of data that was not used for prediction.

loss.unit

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.fun

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.

y

Outcome variable. A character vector containing the column names of the outcome variable.

L2.unit

Geographic unit. A character scalar containing the column name of the geographic unit in survey and census at which outcomes should be aggregated.

Value

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.


autoMrP documentation built on Jan. 21, 2021, 5:07 p.m.