A Python implementation of "Shapley Value Methods for Attribution Modeling in Online Advertising" by Zhao, et al.
How to use:
- Clone this repository
git clone https://github.com/ianchute/shapley-attribution-model.git
- Import one of the two Shapley Attribution Models
from simplified_shapley_attribution_model import SimplifiedShapleyAttributionModel
- Initialize the model
model = SimplifiedShapleyAttributionModel()
- Feed customer journeys into the model (represented by list of lists of integers, where each integer represents a channel, product, or other object that can be attributed to a certain event). Sample data can be found in the
data
folder.
import json
with open("data/sample.json", "r") as f:
journeys = json.load(f)
result = model.attribute(journeys)
- The result is a dictionary of attributions (keys are channels, values are attribution scores; for
OrderedShapleyAttributionModel
, a list of attributions is returned - one for each touchpoint in the journey)
Available models:
SimplifiedShapleyAttributionModel
OrderedShapleyAttributionModel