How to input edge weight for PinSAGE evaluation step

Hi, I’m trying to build the evaluation code based on below github.

I’m trying to do it my own data instead of Movielens dataset.
Instead of data-dict[‘timestamp’] on Movielens data, how can I use the ‘timestamp’ of my graph data as the edge weight?

below screenshot is the graph data g which I created.

when I tried this code : g.edges[‘visited’].data[‘timestamp’]
I got the below error.

It seems that you are passing in a tensor rather than a string to dgl.sampling.select_topk. Instead, you need to call it like

dgl.sampling.select_topk(graph_slice, k, 'timestamp', ...)

where 'timestamp' is the name of your edge weight in the graph.

thanks for your response. I resolved this issue. however, for the prediction, I got the below error… Could you advise?

It seems that your ground truth matrix is still a scipy COO matrix, which does not support indexing. You will need to convert it to a CSR matrix using .tocsr() method. You can see how I did it in evaluate_nn function in the same file.

1 Like