tests/testthat/test_expand_fairness_object.R

test_that("expand_fairness_object values check", {
  efo <- expand_fairness_object(fobject)
  parity_loss_metric_data <- fobject$parity_loss_metric_data
  parity_loss_metric_data$label <- fobject$label

  metrics <- as.character(unique(efo$metric))
  models <- as.character(unique(efo$model))

  # for each value check if corresponds to equal value in metrics_data
  for (model in models) {
    for (metric in metrics) {
      expect_equal(
        efo[efo$metric == metric & efo$model == model, "score"],
        parity_loss_metric_data[parity_loss_metric_data$label == model, metric]
      )
    }
  }
})

Try the fairmodels package in your browser

Any scripts or data that you put into this service are public.

fairmodels documentation built on Oct. 8, 2021, 5:06 p.m.