Author: Azin Ghazimatin (aghazima@mpi-inf.mpg.de)
In this repository, we provide the code for generating counterfactual explanations in random walk-based recommender systems in polynomial time. The explanations are in form of a subset of the user's actions, whose removal displaces the top-most recommendation. User's actions are modeled as the outgoing edges of the user node in her interaction graph. Reference: https://dl.acm.org/doi/pdf/10.1145/3336191.3371824
The relevance of the items to a user is measured based on the their PageRank scores personalized for the user. In local_push.py, the PPR (personalized PageRank) scores are computed using reverse local push algorithm (with approximation guarantee of epsilon). For a given user and her interction graph, the function "cfe_item_centric_algo_poly" in cfe_generator.py returns the counterfactual explanation and the replacement item (the new top-most recommendation).
In toy_example.py, the algorithm is tested on random graphs. For example, in the graph below, the user node is shown in red (node 12). The only item nodes in the graph are nodes 13 an 14. Node 14 has higher PageRank score, hence the top recommendation. Deleting the red edges swaps the rank of the nodes 13 and 14, and makes node 13 the new top recommendation.