shapley_approx: Shapley Value Approximation

View source: R/shapley_approx.R

shapley_approxR Documentation

Shapley Value Approximation

Description

Approximates Shapley Values for a set of items. Shapley Values measure the relative contribution each item has to the overall potential reach if every item was included.

Usage

shapley_approx(
  data,
  items,
  case_weights,
  item_weights,
  depth = 1,
  return = "vector"
)

Arguments

data

A data frame.

items

Columns on which to analyze. Must contain only ones, zeros, or NA. Suggest using is_onezero ahead of time to check.

case_weights

An optional column of case weights to use in the calculations. Rows with NA will be removed from the base.

item_weights

An optional named vector of non-zero weights to associate with each item. Items not specified will be given a default weight of 1.

Examples could be profit, revenue, or simply relative weights.

depth

Number of items needed in order to be considered "reached." Can be any number between 1 to number of items. Default is 1.

return

One of "vector" (default) or "tibble" specifying the type of object to return.

Examples

shapley_approx(
    data = FoodSample,
    items = Bisque:Chili,
    case_weights = weight,
    item_weights = c(Bisque = 9.99, Chicken = 10.29, Tofu = 10.99, Chili = 7.49),
    depth = 1,
    return = "tibble"
)


ttrodrigz/onezero documentation built on May 9, 2023, 2:59 p.m.