Closed zihaozhu93 closed 9 months ago
Hi, please provide the code on how you split the data. And what are the values in the "label" column of the original data?
Hi, please provide the code on how you split the data. And what are the values in the "label" column of the original data?
Thanks reply.
I follow the examples as feat_ranking_example.py
if __name__ == "__main__":
start_time = time.perf_counter()
data = pd.read_csv("data/expose_post/detail_post.csv", sep=",", header=0)
train_data, eval_data = split_by_ratio_chrono(data, test_size=0.2)
label column contains only 0,1
Samples with label 0 in the original data are not included in user_consumed_set
.
Since u are using negative sampling(neg_sampling=True
), try setting all the labels to 1.
Thanks a lot. It works!
hi,there
I've tried follow pinSage example,
the outputs seems training runs well, but eval failed with exception
outputs with keyerror:
n_users: 446354, n_items: 67291, data density: 0.0188 %
============================== PinSageDGL ============================== Training start time: 2023-12-07 18:29:50 train: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 8687/8687 [11:11<00:00, 12.93it/s] Epoch 1 elapsed: 671.941s train_loss: 0.269 item embeds: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 33/33 [00:02<00:00, 11.06it/s] Traceback (most recent call last): ...... pinsage_dgl.fit( File "/data/anaconda3/envs/dgl/lib/python3.9/site-packages/libreco/bases/embed_base.py", line 137, in fit self.trainer.run( File "/data/anaconda3/envs/dgl/lib/python3.9/site-packages/libreco/training/torch_trainer.py", line 128, in run print_metrics( File "/data/anaconda3/envs/dgl/lib/python3.9/site-packages/libreco/evaluation/evaluate.py", line 183, in print_metrics eval_metrics = metrics_fn(data=eval_data, metrics=metrics) File "/data/anaconda3/envs/dgl/lib/python3.9/site-packages/libreco/evaluation/evaluate.py", line 105, in evaluate data = build_eval_transformed_data(model, data, neg_sampling, seed) File "/data/anaconda3/envs/dgl/lib/python3.9/site-packages/libreco/evaluation/computation.py", line 20, in build_eval_transformed_data data.build_negatives(model.n_items, num_neg, seed=seed) File "/data/anaconda3/envs/dgl/lib/python3.9/site-packages/libreco/data/transformed.py", line 142, in build_negatives items_neg = self._sample_neg_items( File "/data/anaconda3/envs/dgl/lib/python3.9/site-packages/libreco/data/transformed.py", line 156, in _sample_neg_items return negatives_from_unconsumed( File "/data/anaconda3/envs/dgl/lib/python3.9/site-packages/libreco/sampling/negatives.py", line 73, in negatives_from_unconsumed if n != i and n not in u_negs and n not in user_consumed_set[u]: KeyError: 0