azinmatin / prince

10 stars 3 forks source link

code problems #1

Open cheng-px opened 4 years ago

cheng-px commented 4 years ago

How does the Amazon data use in the PRINCE?Can you show some code examples?

wayalhruhi commented 4 years ago

how to we use it with the dataset?

wayalhruhi commented 4 years ago

How does the Amazon data use in the PRINCE?Can you show some code examples?

did you figure it out?

azinmatin commented 4 years ago

I used the recent Amazon customer review dataset : https://s3.amazonaws.com/amazon-reviews-pds/readme.html Each line contains information on a user and an item she rated and reviewed. So, you have to create a graph, add a node for each user and item, and for each line in the dataset insert an edge (labeled as rated or reviewed) between the corresponding user and item nodes. You can add weights to the edges as well. The graph I generated was weighted (check out RecWalk paper to see how these weights are computed) and contained category nodes, too. These nodes connect the items of the same category together. Using this graph, the rest is straightforward. You need to initialize a CFE instance: CFE(graph, p, r, alpha, epsilon)

and find the counterfactual explanations using the following function: cfe_instance.cfe_item_centric_algo_poly(source_node, explained_node, candidate_nodes)

cheng-px commented 4 years ago

How does the Amazon data use in the PRINCE?Can you show some code examples?

did you figure it out?

thx,I got it.

wayalhruhi commented 4 years ago

thanks, it's working.

wayalhruhi commented 4 years ago

Could you explain what p and r are in CFE(graph, p, r, alpha, epsilon)? Thanks.

azinmatin commented 4 years ago

Sure. P is a dictionary object whose keys are items and for each item, the value is PPR(., item), which is again a dictionary {item2: PPR(item2, item)}. The PageRank scores are computed using local_reverse_push to guarantee epsilon-approximation. Variable r is similar to p, except that it captures the residual value for each PageRank score.

azinmatin commented 4 years ago

Yes, the graph must be connected. So, reverse local push for item i gives you the PPR(., i). If you need PPR(i, .), you can use the PageRank function in networkx library, but then the approximation guarantees would not be the same.

On Wed, Jul 29, 2020 at 7:20 AM Rushikesh Wayal notifications@github.com wrote:

Thanks, but local_reverse_push, only gives PPR for connected nodes right? What if I need PPR for all items, wrt to a certain item2.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/azinmatin/prince/issues/1#issuecomment-665437259, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEYREPDNFV5IHK7I2E34SQ3R56WR3ANCNFSM4N36NVHA .

wayalhruhi commented 4 years ago

Thanks a lot.