yingtaoluo / Spatial-Temporal-Attention-Network-for-POI-Recommendation

Codes for a WWW'21 Paper. POI recommender system for location/trajectory prediction.
https://doi.org/10.1145/3442381.3449998
164 stars 39 forks source link

Some questions about code #11

Closed kevin-xuan closed 2 years ago

kevin-xuan commented 2 years ago

Hello! I'm interested in your work. Thanks for sharing the dataset and the resources. I have some questions. Firstly, you set part=100 in line 221 in train.py, it means that you only use the first 100 users to train model? Secondly, in line 31 in layers.py, you use torch.mul function to tackle the self_delta, but it should be torch.add function in Equation (9) in your paper. And the scaled factor "d" is not reflected in your code? Thirdly, in line 82 in layers.py, the interpolation embedding calculation equation is different from Equation (4) in your paper? vsl, vsu, vtl, vtu = (delta_s - self.sl).unsqueeze(-1).expand(-1, -1, -1, self.emb_size), \ (self.su - delta_s).unsqueeze(-1).expand(-1, -1, -1, self.emb_size), \ (delta_t - self.tl).unsqueeze(-1).expand(-1, -1, -1, self.emb_size), \ (self.tu - delta_t).unsqueeze(-1).expand(-1, -1, -1, self.emb_size) space_interval = (esl vsu + esu vsl) / (self.su - self.sl), but it should be: space_interval = (esl vsl + esu vsu) / (self.su - self.sl) according to Equation (4),which formula is wrong?

kevin-xuan commented 2 years ago

Another problem is that you do not provide pre-processing source code to generate NYC.npy and NYC_POI.npy file. How do you remove inactive POI, inactive users, etc.? What is the specific setting?

yingtaoluo commented 2 years ago

Hi. First question: No, if you use smaller batches to evaluate in case that your machine cannot support large data/model, it has to be the average results of all users. Using only the first 100 is strange. Second and third questions: We have two equations listed in the paper. It is the second way to implement it. Use your own codes if you prefer the first one. Preprocessing can refer to settings in the paper and other issues at the repository.

On Mon, Oct 25, 2021 at 8:31 PM kevin-xuan @.***> wrote:

Another problem is that you do not provide pre-processing source code to generate NYC.npy and NYC_POI.npy file. How do you remove inactive POI, inactive users, etc.? What is the specific setting?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/yingtaoluo/Spatial-Temporal-Attention-Network-for-POI-Recommendation/issues/11#issuecomment-950876111, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH5PX46JPJP2MZHQBLFXHGDUIVEWJANCNFSM5GR2AYSA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

kevin-xuan commented 2 years ago

Thank you for your reply! But I don't think you understand what I mean. I think that either the source code you provided is defective, or Equation (4) is defective about the interpolation. Besides, you just stated in your paper that you follow the settings of previous works, but I am wondering what the specific settings are. For example, users with less than how many records are deleted, and POIs with less than how many visits are deleted?

yingtaoluo commented 2 years ago

Thank you for pointing that out. I do understand your meaning, but it may not be a non-trivial technical thing. Since both esl and esu are initialized as nn.Embedding(2, embed_dim, padding_idx=0), you can regard them as "esu" and "esl" if you care about the naming. For preprocessing, we are the same as TiSASRec, as stated in the paper since you can think of STAN as adding a spatio module & modifying the neural architecture to accommodate PIF than TiSASRec. You can develop your own protocol when developing your own model, which does not matter for the fairness of comparison. Works in the venue do not have standard protocol. Make sure to make a fair comparison though.

On Tue, Oct 26, 2021 at 1:13 PM kevin-xuan @.***> wrote:

Thank you for your reply! But I don't think you understand what I mean. I think that either the source code you provided is defective, or Equation (4) is defective about the interpolation. Besides, you just stated in your paper that you follow the settings of previous works, but I am wondering what the specific settings are. For example, users with less than how many records are deleted, and POIs with less than how many visits are deleted?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/yingtaoluo/Spatial-Temporal-Attention-Network-for-POI-Recommendation/issues/11#issuecomment-951567803, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH5PX4734Q4CXO5DNG4ONM3UIY2HHANCNFSM5GR2AYSA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

kevin-xuan commented 2 years ago

Thank you for your reply!

kevin-xuan commented 2 years ago

I'm sorry to bother you again,I try to write the "preprocessing.py" to preprocess the raw data file, e.g., NYC.txt and TKY.txt. Users with less than 5 records are deleted, and POIs with less than 10 visits are deleted. However, I have some questions.
Firstly, the preprocessed data do not accord with the data description in Table 1 in your paper, for example, #users are 1083 and 2293 in NYC and TKY dataset, respectively. Secondly, I sort all the user histories by the identifiers of the POIs, and then process them to get the data that matches the two files(NYC.npy and NYC_POI.npy) you provided, the results are consistent with those described in your paper. However, if I do not sort all the user histories by the identifiers of the POIs and directly process the raw data to generate NYC.npy and NYC_POI.npy, the results are worse than those described in your paper. I can't understand the gap between the two approaches. Thirdly, as for Gowalla dataset, I attempt to use different user thresholds (e.g., 5) and poi thresholds (e.g., 10), but the statistics never agree with those described in the paper.

kevin-xuan commented 2 years ago

Divide the dataset into different proportions of users to test the performance and then average. And you set "part=100" in line 221 in train.py, which means you use the first 100 users (first proportion) to test performance. If the number of uers is 1000, we need to set "part" to {100, 200, 300, ..., 1000} respectively and run the "train.py" 10 times and average the 10 results? If part=100, then "trajs, mat1, mat2t, labels, lens = trajs[:part], mat1[:part], mat2t[:part], labels[:part], lens[:part]" If part=200, then "trajs, mat1, mat2t, labels, lens = trajs[part-100:part], mat1[part-100:part], mat2t[part-100:part], labels[part-100:part], lens[part-100:part]". Is that so? In this way, all the users is divided into different proportions ([:100], [100,200], [200,300],...[900,1000]) and avarage the results of 10 proportions.

yingtaoluo commented 2 years ago

Yes, exactly.

On Sun, Oct 31, 2021 at 3:46 PM kevin-xuan @.***> wrote:

Divide the dataset into different proportions of users to test the performance and then average. And you set "part=100" in line 221 in train.py, which means you use the first 100 users (first proportion) to test performance. If the number of uers is 1000, we need to set "part" to {100, 200, 300, ..., 1000} respectively and run the "train.py" 10 times and average the 10 results? If part=100, then "trajs, mat1, mat2t, labels, lens = trajs[:part], mat1[:part], mat2t[:part], labels[:part], lens[:part]" If part=200, then "trajs, mat1, mat2t, labels, lens = trajs[part-100:part], mat1[part-100:part], mat2t[part-100:part], labels[part-100:part], lens[part-100:part]". Is that so? In this way, all the users is divided into different proportions ([:100], [100,200], [200,300],...[900,1000]) and avarage the results of 10 proportions.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/yingtaoluo/Spatial-Temporal-Attention-Network-for-POI-Recommendation/issues/11#issuecomment-955652797, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH5PX4YU5EDGIN6ZOWYK4MTUJTX4TANCNFSM5GR2AYSA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.