warprec 2.1.4__tar.gz → 2.1.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {warprec-2.1.4 → warprec-2.1.6}/PKG-INFO +1 -1
- {warprec-2.1.4 → warprec-2.1.6}/pyproject.toml +1 -1
- {warprec-2.1.4 → warprec-2.1.6}/warprec/common/initialize.py +4 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/data/dataset.py +65 -44
- {warprec-2.1.4 → warprec-2.1.6}/warprec/data/entities/common.py +14 -4
- {warprec-2.1.4 → warprec-2.1.6}/warprec/data/entities/interactions.py +18 -18
- {warprec-2.1.4 → warprec-2.1.6}/warprec/data/entities/sessions.py +1 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/data/entities/train_structures/session_structures.py +12 -3
- {warprec-2.1.4 → warprec-2.1.6}/warprec/data/entities/transactions.py +2 -1
- {warprec-2.1.4 → warprec-2.1.6}/warprec/data/eval_loaders.py +34 -15
- warprec-2.1.6/warprec/data/ranking.py +376 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/data/splitting/strategies.py +8 -4
- {warprec-2.1.4 → warprec-2.1.6}/warprec/data/writer/azureblob_writer.py +2 -1
- {warprec-2.1.4 → warprec-2.1.6}/warprec/data/writer/base_writer.py +18 -3
- {warprec-2.1.4 → warprec-2.1.6}/warprec/data/writer/local_writer.py +2 -1
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/evaluator.py +50 -23
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/factory.py +1 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/pipelines/design.py +2 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/pipelines/estimate.py +5 -13
- {warprec-2.1.4 → warprec-2.1.6}/warprec/pipelines/eval.py +3 -1
- {warprec-2.1.4 → warprec-2.1.6}/warprec/pipelines/remotes/data.py +1 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/pipelines/remotes/ml.py +2 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/reranking/base.py +15 -2
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/sequential_recommender/lightsans.py +5 -3
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/trainer/objectives.py +3 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/config/evaluation_configuration.py +34 -2
- warprec-2.1.4/warprec/data/ranking.py +0 -226
- {warprec-2.1.4 → warprec-2.1.6}/LICENSE +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/README.md +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/common/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/common/run_state.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/common/std_logs.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/data/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/data/entities/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/data/entities/context.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/data/entities/knowledge.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/data/entities/multimodal.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/data/entities/train_structures/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/data/entities/train_structures/custom_collate_fn.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/data/entities/train_structures/interaction_structures.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/data/filtering.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/data/reader/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/data/reader/azureblob_reader.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/data/reader/base_reader.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/data/reader/local_reader.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/data/schema.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/data/splitting/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/data/splitting/splitter.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/data/writer/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/accuracy/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/accuracy/auc.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/accuracy/f1.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/accuracy/gauc.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/accuracy/hit_rate.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/accuracy/lauc.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/accuracy/logloss.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/accuracy/map.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/accuracy/mar.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/accuracy/mrr.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/accuracy/ndcg.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/accuracy/precision.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/accuracy/recall.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/base_metric.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/bias/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/bias/aclt.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/bias/aplt.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/bias/arp.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/bias/long_tail.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/bias/pop_reo.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/bias/pop_rsp.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/coverage/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/coverage/item_coverage.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/coverage/numretrieved.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/coverage/user_coverage.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/coverage/user_coverage_at_n.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/debiased/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/debiased/base.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/debiased/dcg.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/debiased/recall.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/diversity/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/diversity/gini_index.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/diversity/shannon_entropy.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/diversity/srecall.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/fairness/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/fairness/biasdisparitybd.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/fairness/biasdisparitybr.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/fairness/biasdisparitybs.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/fairness/itemmadranking.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/fairness/itemmadrating.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/fairness/reo.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/fairness/rsp.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/fairness/usermadranking.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/fairness/usermadrating.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/multiobjective/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/multiobjective/euclideandistance.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/multiobjective/hypervolume.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/novelty/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/novelty/efd.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/novelty/epc.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/novelty/novelty_profile.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/rating/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/rating/mae.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/rating/mse.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/metrics/rating/rmse.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/propensity.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/evaluation/statistical_significance.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/pipelines/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/pipelines/common.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/pipelines/remotes/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/pipelines/swarm.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/pipelines/train.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/base_recommender.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/callbacks.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/cdae.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/diffrec.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/ease.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/elsa.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/macridvae.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/multidae.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/multivae.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/sansa.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/graph_based/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/graph_based/dgcf.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/graph_based/egcf.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/graph_based/esigcf.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/graph_based/gcmc.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/graph_based/graph_utils.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightccf.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgcl.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgcn.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgcnpp.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgode.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/graph_based/macrgcn.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/graph_based/mixrec.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/graph_based/ngcf.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/graph_based/paac.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/graph_based/popdcl.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/graph_based/recdcl.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/graph_based/rp3beta.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/graph_based/sgcl.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/graph_based/sgl.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/graph_based/simgcl.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/graph_based/simrec.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/graph_based/ultragcn.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/graph_based/xsimgcl.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/knn/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/knn/itemknn.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/knn/itemknntd.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/knn/userknn.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/knn/userknntd.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/admmslim.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/bpr.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/fism.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/ials.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/ials2008.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/macrmf.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/slim.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/neural/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/neural/convncf.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/neural/neumf.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/collaborative_filtering_recommender/neural/twotower.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/content_based_recommender/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/content_based_recommender/vsm.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/context_aware_recommender/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/context_aware_recommender/afm.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/context_aware_recommender/dcn.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/context_aware_recommender/dcnv2.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/context_aware_recommender/deepfm.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/context_aware_recommender/fm.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/context_aware_recommender/nfm.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/context_aware_recommender/wideanddeep.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/context_aware_recommender/xdeepfm.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/hybrid_recommender/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/hybrid_recommender/addease.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/hybrid_recommender/attributeitemknn.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/hybrid_recommender/attributeuserknn.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/hybrid_recommender/cease.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/knowledge_aware_recommender/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/knowledge_aware_recommender/cke.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/knowledge_aware_recommender/kahfm.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/knowledge_aware_recommender/kgat.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/knowledge_aware_recommender/kgcn.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/knowledge_aware_recommender/kgflex.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/knowledge_aware_recommender/kgin.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/knowledge_aware_recommender/knowledge_utils.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/knowledge_aware_recommender/ripplenet.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/layers.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/losses.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/lr_scheduler_wrapper.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/multimodal_recommender/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/multimodal_recommender/bm3.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/multimodal_recommender/freedom.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/multimodal_recommender/lattice.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/multimodal_recommender/mgcn.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/multimodal_recommender/mmgcn.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/multimodal_recommender/multimodal_utils.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/multimodal_recommender/vbpr.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/optimizer_wrapper.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/proxy.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/reranking/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/reranking/calibration.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/reranking/factory.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/reranking/mmr.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/sequential_recommender/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/sequential_recommender/bert4rec.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/sequential_recommender/bsarec.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/sequential_recommender/caser.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/sequential_recommender/cl4srec.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/sequential_recommender/core.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/sequential_recommender/duorec.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/sequential_recommender/esasrec.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/sequential_recommender/fossil.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/sequential_recommender/gru4rec.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/sequential_recommender/gsasrec.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/sequential_recommender/linrec.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/sequential_recommender/narm.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/sequential_recommender/sasrec.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/sequential_recommender/stan.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/similarities.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/trainer/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/trainer/dashboard_callbacks.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/trainer/logger_callbacks.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/trainer/runtime.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/trainer/scheduler_wrapper.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/trainer/search_algorithm_wrapper.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/trainer/trainer.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/unpersonalized_recommender/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/unpersonalized_recommender/pop.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/recommenders/unpersonalized_recommender/random.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/run.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/serve.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/serving/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/serving/api.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/serving/app.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/serving/catalogue.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/serving/context.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/serving/deployments.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/serving/errors.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/serving/mcp.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/serving/payload.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/serving/schemas.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/serving/servable.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/callback.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/config/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/config/common.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/config/config.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/config/dashboard_configuration.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/config/estimate_configuration.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/config/general_configuration.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/config/model_configuration.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/config/reader_configuration.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/config/recommender_model_config/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/autoencoder_config.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/graph_based_config.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/knn_config.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/latent_factor_config.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/neural_config.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/config/recommender_model_config/content_based_config.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/config/recommender_model_config/context_aware_config.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/config/recommender_model_config/hybrid_config.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/config/recommender_model_config/knowledge_aware_config.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/config/recommender_model_config/multimodal_config.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/config/recommender_model_config/sequential_model_config.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/config/recommender_model_config/unpersonalized_config.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/config/rerank_configuration.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/config/run_configuration.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/config/search_space_wrapper.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/config/serving_configuration.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/config/splitter_configuration.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/config/training_configuration.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/config/writer_configuration.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/enums.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/helpers.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/logger/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/logger/logger.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/pause.py +0 -0
- {warprec-2.1.4 → warprec-2.1.6}/warprec/utils/registry.py +0 -0
|
@@ -541,6 +541,8 @@ def dataset_preparation(
|
|
|
541
541
|
dataset.get_sampled_evaluation_dataloader(
|
|
542
542
|
num_negatives=config.evaluation.num_negatives,
|
|
543
543
|
seed=config.evaluation.seed,
|
|
544
|
+
negative_sampling=config.evaluation.negative_sampling,
|
|
545
|
+
neg_alpha=config.evaluation.neg_alpha,
|
|
544
546
|
)
|
|
545
547
|
|
|
546
548
|
# Initialize the contextual evaluation structures
|
|
@@ -551,6 +553,8 @@ def dataset_preparation(
|
|
|
551
553
|
dataset.get_sampled_contextual_evaluation_dataloader(
|
|
552
554
|
num_negatives=config.evaluation.num_negatives,
|
|
553
555
|
seed=config.evaluation.seed,
|
|
556
|
+
negative_sampling=config.evaluation.negative_sampling,
|
|
557
|
+
neg_alpha=config.evaluation.neg_alpha,
|
|
554
558
|
)
|
|
555
559
|
|
|
556
560
|
logger.msg("Preparing main dataset inner structures for evaluation.")
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# pylint: disable = too-many-branches, too-many-statements
|
|
2
|
-
from typing import Tuple, Optional, List, Any, Dict
|
|
2
|
+
from typing import Callable, Tuple, Optional, List, Any, Dict
|
|
3
3
|
|
|
4
4
|
import math
|
|
5
5
|
|
|
6
6
|
import numpy as np
|
|
7
7
|
import torch
|
|
8
8
|
from torch import Tensor
|
|
9
|
-
from torch.utils.data import DataLoader
|
|
9
|
+
from torch.utils.data import DataLoader, Dataset as TorchDataset
|
|
10
10
|
from scipy.sparse import csr_matrix, coo_matrix
|
|
11
11
|
|
|
12
12
|
import narwhals as nw
|
|
@@ -177,6 +177,7 @@ class Dataset:
|
|
|
177
177
|
|
|
178
178
|
# Initialize the dataset dataloader
|
|
179
179
|
self._precomputed_dataloader: Dict[str, Any] = {}
|
|
180
|
+
self._evaluation_samples: Dict[str, TorchDataset] = {}
|
|
180
181
|
|
|
181
182
|
# If side information data has been provided, we filter the main dataset
|
|
182
183
|
if mat_side_data is not None:
|
|
@@ -956,20 +957,14 @@ class Dataset:
|
|
|
956
957
|
DataLoader: DataLoader that yields batches of interactions
|
|
957
958
|
(eval_batch, user_indices).
|
|
958
959
|
"""
|
|
959
|
-
key = f"full_{self._serialize_dataloader_kwargs(kwargs)}"
|
|
960
|
-
if key not in self._precomputed_dataloader:
|
|
961
|
-
eval_sparse = self.eval_set.get_sparse()
|
|
962
960
|
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
batch_size=self.batch_size,
|
|
967
|
-
shuffle=False,
|
|
968
|
-
collate_fn=sparse_eval_collate,
|
|
969
|
-
**kwargs,
|
|
970
|
-
)
|
|
961
|
+
def build() -> EvaluationDataset:
|
|
962
|
+
eval_sparse = self.eval_set.get_sparse()
|
|
963
|
+
return EvaluationDataset(eval_interactions=eval_sparse)
|
|
971
964
|
|
|
972
|
-
return self.
|
|
965
|
+
return self._evaluation_loader(
|
|
966
|
+
"full", build, kwargs, collate_fn=sparse_eval_collate
|
|
967
|
+
)
|
|
973
968
|
|
|
974
969
|
def get_sampled_evaluation_dataloader(
|
|
975
970
|
self,
|
|
@@ -994,16 +989,12 @@ class Dataset:
|
|
|
994
989
|
DataLoader: DataLoader that yields batches
|
|
995
990
|
of interactions (pos_items, neg_items, user_indices)
|
|
996
991
|
"""
|
|
997
|
-
key = (
|
|
998
|
-
f"sampled_{num_negatives}_{seed}_{negative_sampling}_{neg_alpha}_"
|
|
999
|
-
f"{self._serialize_dataloader_kwargs(kwargs)}"
|
|
1000
|
-
)
|
|
1001
992
|
|
|
1002
|
-
|
|
993
|
+
def build() -> SampledEvaluationDataset:
|
|
1003
994
|
train_sparse = self.train_set.get_sparse()
|
|
1004
995
|
eval_sparse = self.eval_set.get_sparse()
|
|
1005
996
|
|
|
1006
|
-
|
|
997
|
+
return SampledEvaluationDataset(
|
|
1007
998
|
train_interactions=train_sparse,
|
|
1008
999
|
eval_interactions=eval_sparse,
|
|
1009
1000
|
num_negatives=num_negatives,
|
|
@@ -1011,15 +1002,12 @@ class Dataset:
|
|
|
1011
1002
|
negative_sampling=negative_sampling,
|
|
1012
1003
|
neg_alpha=neg_alpha,
|
|
1013
1004
|
)
|
|
1014
|
-
self._precomputed_dataloader[key] = DataLoader(
|
|
1015
|
-
dataset,
|
|
1016
|
-
batch_size=self.batch_size,
|
|
1017
|
-
shuffle=False,
|
|
1018
|
-
collate_fn=dataset.collate_fn,
|
|
1019
|
-
**kwargs,
|
|
1020
|
-
)
|
|
1021
1005
|
|
|
1022
|
-
return self.
|
|
1006
|
+
return self._evaluation_loader(
|
|
1007
|
+
f"sampled_{num_negatives}_{seed}_{negative_sampling}_{neg_alpha}",
|
|
1008
|
+
build,
|
|
1009
|
+
kwargs,
|
|
1010
|
+
)
|
|
1023
1011
|
|
|
1024
1012
|
def get_contextual_evaluation_dataloader(self, **kwargs: Any) -> DataLoader:
|
|
1025
1013
|
"""Retrieve the full contextual evaluation DataLoader for the dataset.
|
|
@@ -1033,8 +1021,8 @@ class Dataset:
|
|
|
1033
1021
|
Returns:
|
|
1034
1022
|
DataLoader: The contextual data loader.
|
|
1035
1023
|
"""
|
|
1036
|
-
|
|
1037
|
-
|
|
1024
|
+
|
|
1025
|
+
def build() -> ContextualEvaluationDataset:
|
|
1038
1026
|
eval_data = self.eval_set.get_df()
|
|
1039
1027
|
|
|
1040
1028
|
# Retrieve labels to pre-compute eval data
|
|
@@ -1078,18 +1066,15 @@ class Dataset:
|
|
|
1078
1066
|
# but if we need to drop other nulls:
|
|
1079
1067
|
# eval_data = eval_data.drop_nulls(subset=[user_label, item_label])
|
|
1080
1068
|
|
|
1081
|
-
|
|
1069
|
+
return ContextualEvaluationDataset(
|
|
1082
1070
|
eval_data=eval_data,
|
|
1083
1071
|
user_id_label=user_label,
|
|
1084
1072
|
item_id_label=item_label,
|
|
1085
1073
|
context_labels=context_labels,
|
|
1086
1074
|
context=self._context_spec,
|
|
1087
1075
|
)
|
|
1088
|
-
self._precomputed_dataloader[key] = DataLoader(
|
|
1089
|
-
dataset, batch_size=self.batch_size, shuffle=False, **kwargs
|
|
1090
|
-
)
|
|
1091
1076
|
|
|
1092
|
-
return self.
|
|
1077
|
+
return self._evaluation_loader("full_contextual", build, kwargs)
|
|
1093
1078
|
|
|
1094
1079
|
def get_sampled_contextual_evaluation_dataloader(
|
|
1095
1080
|
self,
|
|
@@ -1113,12 +1098,8 @@ class Dataset:
|
|
|
1113
1098
|
Returns:
|
|
1114
1099
|
DataLoader: The sampled contextual loader.
|
|
1115
1100
|
"""
|
|
1116
|
-
key = (
|
|
1117
|
-
f"sampled_contextual_{num_negatives}_{seed}_{negative_sampling}_{neg_alpha}_"
|
|
1118
|
-
f"{self._serialize_dataloader_kwargs(kwargs)}"
|
|
1119
|
-
)
|
|
1120
1101
|
|
|
1121
|
-
|
|
1102
|
+
def build() -> SampledContextualEvaluationDataset:
|
|
1122
1103
|
train_sparse = self.train_set.get_sparse()
|
|
1123
1104
|
eval_data = self.eval_set.get_df()
|
|
1124
1105
|
|
|
@@ -1156,7 +1137,7 @@ class Dataset:
|
|
|
1156
1137
|
nw.col(f"{item_label}_idx").alias(item_label),
|
|
1157
1138
|
).drop(f"{user_label}_idx", f"{item_label}_idx")
|
|
1158
1139
|
|
|
1159
|
-
|
|
1140
|
+
return SampledContextualEvaluationDataset(
|
|
1160
1141
|
train_interactions=train_sparse,
|
|
1161
1142
|
eval_data=eval_data,
|
|
1162
1143
|
user_id_label=user_label,
|
|
@@ -1169,15 +1150,55 @@ class Dataset:
|
|
|
1169
1150
|
neg_alpha=neg_alpha,
|
|
1170
1151
|
context=self._context_spec,
|
|
1171
1152
|
)
|
|
1172
|
-
|
|
1153
|
+
|
|
1154
|
+
return self._evaluation_loader(
|
|
1155
|
+
f"sampled_contextual_{num_negatives}_{seed}_{negative_sampling}_{neg_alpha}",
|
|
1156
|
+
build,
|
|
1157
|
+
kwargs,
|
|
1158
|
+
)
|
|
1159
|
+
|
|
1160
|
+
def _evaluation_loader(
|
|
1161
|
+
self,
|
|
1162
|
+
key: str,
|
|
1163
|
+
build: Callable[[], TorchDataset],
|
|
1164
|
+
kwargs: Dict[str, Any],
|
|
1165
|
+
collate_fn: Optional[Callable] = None,
|
|
1166
|
+
) -> DataLoader:
|
|
1167
|
+
"""Wrap an evaluation sample in a DataLoader, building each only once.
|
|
1168
|
+
|
|
1169
|
+
The sample and the loader are cached apart. The sample is what costs:
|
|
1170
|
+
the sampled strategies draw every user's negatives when it is built. A
|
|
1171
|
+
loader only wraps it, and its worker settings differ between the train
|
|
1172
|
+
pipeline's preparation, which has none, and each trial, which sizes
|
|
1173
|
+
them from its own CPUs. Were both cached under one key, a trial would
|
|
1174
|
+
never find the sample prepared for it and would draw it again.
|
|
1175
|
+
|
|
1176
|
+
Args:
|
|
1177
|
+
key (str): What identifies the sample: the strategy and every
|
|
1178
|
+
parameter the draw depends on, the seed included.
|
|
1179
|
+
build (Callable[[], TorchDataset]): Builds the sample on a miss.
|
|
1180
|
+
kwargs (Dict[str, Any]): The keyword arguments to pass to
|
|
1181
|
+
DataLoader initialization.
|
|
1182
|
+
collate_fn (Optional[Callable]): How a batch is assembled, when the
|
|
1183
|
+
sample does not say so itself.
|
|
1184
|
+
|
|
1185
|
+
Returns:
|
|
1186
|
+
DataLoader: The loader over the cached sample.
|
|
1187
|
+
"""
|
|
1188
|
+
loader_key = f"{key}_{self._serialize_dataloader_kwargs(kwargs)}"
|
|
1189
|
+
if loader_key not in self._precomputed_dataloader:
|
|
1190
|
+
if key not in self._evaluation_samples:
|
|
1191
|
+
self._evaluation_samples[key] = build()
|
|
1192
|
+
dataset = self._evaluation_samples[key]
|
|
1193
|
+
self._precomputed_dataloader[loader_key] = DataLoader(
|
|
1173
1194
|
dataset,
|
|
1174
1195
|
batch_size=self.batch_size,
|
|
1175
1196
|
shuffle=False,
|
|
1176
|
-
collate_fn=dataset
|
|
1197
|
+
collate_fn=collate_fn or getattr(dataset, "collate_fn", None),
|
|
1177
1198
|
**kwargs,
|
|
1178
1199
|
)
|
|
1179
1200
|
|
|
1180
|
-
return self._precomputed_dataloader[
|
|
1201
|
+
return self._precomputed_dataloader[loader_key]
|
|
1181
1202
|
|
|
1182
1203
|
@staticmethod
|
|
1183
1204
|
def _serialize_dataloader_kwargs(kwargs: dict[str, Any]) -> str:
|
|
@@ -8,6 +8,7 @@ from torch.utils.data import DataLoader, Dataset
|
|
|
8
8
|
|
|
9
9
|
USER_INDEX = "__uidx__"
|
|
10
10
|
ITEM_INDEX = "__iidx__"
|
|
11
|
+
ROW_INDEX = "__row__"
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
def seed_worker(worker_id: int) -> None:
|
|
@@ -84,6 +85,11 @@ def map_to_index_space(
|
|
|
84
85
|
entities each used to carry their own copy of it, and a copy is a chance for
|
|
85
86
|
the two to disagree about which rows exist.
|
|
86
87
|
|
|
88
|
+
A join does not promise to keep the rows in their input order (polars does
|
|
89
|
+
not), so each row also carries its position in the input, ``ROW_INDEX``.
|
|
90
|
+
Sorting on it after the indices keeps repeated (user, item) rows in file
|
|
91
|
+
order, which is what the 'first' and 'last' duplicate policies mean.
|
|
92
|
+
|
|
87
93
|
Args:
|
|
88
94
|
data (DataFrame[Any]): The raw interactions.
|
|
89
95
|
user_label (str): The name of the user column.
|
|
@@ -94,7 +100,7 @@ def map_to_index_space(
|
|
|
94
100
|
indices. Left out, every column of the input is kept.
|
|
95
101
|
|
|
96
102
|
Returns:
|
|
97
|
-
DataFrame[Any]: The frame with the index columns attached.
|
|
103
|
+
DataFrame[Any]: The frame with the index and row position columns attached.
|
|
98
104
|
"""
|
|
99
105
|
namespace = nw.get_native_namespace(data)
|
|
100
106
|
umap_df = nw.from_dict(
|
|
@@ -112,10 +118,14 @@ def map_to_index_space(
|
|
|
112
118
|
native_namespace=namespace,
|
|
113
119
|
)
|
|
114
120
|
|
|
115
|
-
mapped =
|
|
116
|
-
|
|
121
|
+
mapped = (
|
|
122
|
+
data.with_row_index(ROW_INDEX)
|
|
123
|
+
.join(umap_df, on=user_label, how="inner")
|
|
124
|
+
.join(imap_df, on=item_label, how="inner")
|
|
117
125
|
)
|
|
118
126
|
|
|
119
127
|
if keep is None:
|
|
120
128
|
return mapped
|
|
121
|
-
return mapped.select(
|
|
129
|
+
return mapped.select(
|
|
130
|
+
[nw.col(c) for c in (*keep, USER_INDEX, ITEM_INDEX, ROW_INDEX)]
|
|
131
|
+
)
|
|
@@ -16,6 +16,7 @@ from warprec.data.entities.train_structures import (
|
|
|
16
16
|
)
|
|
17
17
|
from warprec.data.entities.common import (
|
|
18
18
|
ITEM_INDEX,
|
|
19
|
+
ROW_INDEX,
|
|
19
20
|
USER_INDEX,
|
|
20
21
|
map_to_index_space,
|
|
21
22
|
seeded_dataloader,
|
|
@@ -98,16 +99,13 @@ class Interactions:
|
|
|
98
99
|
self._umap = user_mapping
|
|
99
100
|
self._imap = item_mapping
|
|
100
101
|
|
|
101
|
-
#
|
|
102
|
+
# Align side information (if present) with the catalogue
|
|
102
103
|
if self._inter_side is not None:
|
|
103
|
-
|
|
104
|
-
#
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
# Order side information to be in the same order of the dataset (by item index)
|
|
110
|
-
# Create mapping DF for items
|
|
104
|
+
# The lookup is indexed by item index, so it holds one row per item of
|
|
105
|
+
# the catalogue in index order, whichever items this split happens to
|
|
106
|
+
# contain: a catalogue that keeps unseen items, or held-out cold
|
|
107
|
+
# items, is wider than the items of any split. An item without
|
|
108
|
+
# attributes gets 0, the index every feature reserves for unknown.
|
|
111
109
|
imap_df = nw.from_dict(
|
|
112
110
|
{
|
|
113
111
|
self.item_label: list(item_mapping.keys()),
|
|
@@ -115,10 +113,8 @@ class Interactions:
|
|
|
115
113
|
},
|
|
116
114
|
native_namespace=nw.get_native_namespace(self._inter_side),
|
|
117
115
|
)
|
|
118
|
-
|
|
119
|
-
# Join to get the order, sort, and drop temp column
|
|
120
116
|
self._inter_side = (
|
|
121
|
-
self._inter_side
|
|
117
|
+
imap_df.join(self._inter_side, on=self.item_label, how="left")
|
|
122
118
|
.sort("__order__")
|
|
123
119
|
.drop("__order__")
|
|
124
120
|
)
|
|
@@ -127,14 +123,17 @@ class Interactions:
|
|
|
127
123
|
feature_cols = [c for c in self._inter_side.columns if c != self.item_label]
|
|
128
124
|
|
|
129
125
|
# Create the lookup tensor for side information
|
|
130
|
-
|
|
131
|
-
|
|
126
|
+
side_values = (
|
|
127
|
+
self._inter_side.select(feature_cols)
|
|
128
|
+
.with_columns(nw.all().fill_null(0))
|
|
129
|
+
.to_numpy()
|
|
130
|
+
)
|
|
132
131
|
side_tensor = torch.tensor(side_values, dtype=torch.long)
|
|
133
132
|
|
|
134
133
|
# Create the padding row (zeros)
|
|
135
134
|
padding_row = torch.zeros((1, side_tensor.shape[1]), dtype=torch.long)
|
|
136
135
|
|
|
137
|
-
#
|
|
136
|
+
# The padding row goes last, at index n_items, like every item lookup
|
|
138
137
|
self._inter_side_tensor = torch.cat([side_tensor, padding_row], dim=0)
|
|
139
138
|
|
|
140
139
|
# Store the feature labels
|
|
@@ -244,14 +243,15 @@ class Interactions:
|
|
|
244
243
|
)
|
|
245
244
|
|
|
246
245
|
# Sorted so that the arrays are in a reproducible order and line up
|
|
247
|
-
# with one another however the frame arrived.
|
|
246
|
+
# with one another however the frame arrived. Repeated pairs stay in
|
|
247
|
+
# file order, which the 'first' and 'last' duplicate policies rely on.
|
|
248
248
|
mapped_df = map_to_index_space(
|
|
249
249
|
self._inter_df,
|
|
250
250
|
self.user_label,
|
|
251
251
|
self.item_label,
|
|
252
252
|
self._umap,
|
|
253
253
|
self._imap,
|
|
254
|
-
).sort([USER_INDEX, ITEM_INDEX])
|
|
254
|
+
).sort([USER_INDEX, ITEM_INDEX, ROW_INDEX])
|
|
255
255
|
|
|
256
256
|
self._flat_users = mapped_df.select(USER_INDEX).to_numpy().flatten()
|
|
257
257
|
self._flat_items = mapped_df.select(ITEM_INDEX).to_numpy().flatten()
|
|
@@ -310,7 +310,7 @@ class Interactions:
|
|
|
310
310
|
self.item_label,
|
|
311
311
|
self._umap,
|
|
312
312
|
self._imap,
|
|
313
|
-
).sort([USER_INDEX, ITEM_INDEX])
|
|
313
|
+
).sort([USER_INDEX, ITEM_INDEX, ROW_INDEX])
|
|
314
314
|
|
|
315
315
|
users = mapped_df.select(USER_INDEX).to_numpy().flatten()
|
|
316
316
|
items = mapped_df.select(ITEM_INDEX).to_numpy().flatten()
|
|
@@ -317,6 +317,7 @@ class Sessions:
|
|
|
317
317
|
dataset = SlidingWindowDataset(
|
|
318
318
|
flat_items=self._flat_items,
|
|
319
319
|
window_starts=window_starts_flat.astype(np.int64),
|
|
320
|
+
window_ends=self._user_offsets[window_user_ids + 1].astype(np.int64),
|
|
320
321
|
window_users=window_user_ids.astype(np.int64),
|
|
321
322
|
sparse_matrix=self._inter_sparse,
|
|
322
323
|
max_seq_len=max_seq_len,
|
{warprec-2.1.4 → warprec-2.1.6}/warprec/data/entities/train_structures/session_structures.py
RENAMED
|
@@ -201,12 +201,18 @@ class SlidingWindowDataset(Dataset):
|
|
|
201
201
|
Dataset for Sequence-to-Sequence training.
|
|
202
202
|
|
|
203
203
|
Sampled Output: (InputSequence, NegativeSamplesMatrix)
|
|
204
|
+
|
|
205
|
+
A window is cut from ``flat_items`` and ends at its user's end in that same
|
|
206
|
+
array, ``window_ends``. The interaction matrix cannot give that end: it
|
|
207
|
+
holds one cell per (user, item) pair, so a user who repeats an item has
|
|
208
|
+
fewer cells than rows.
|
|
204
209
|
"""
|
|
205
210
|
|
|
206
211
|
def __init__(
|
|
207
212
|
self,
|
|
208
213
|
flat_items: np.ndarray,
|
|
209
214
|
window_starts: np.ndarray,
|
|
215
|
+
window_ends: np.ndarray,
|
|
210
216
|
window_users: np.ndarray,
|
|
211
217
|
sparse_matrix: csr_matrix,
|
|
212
218
|
max_seq_len: int,
|
|
@@ -214,11 +220,15 @@ class SlidingWindowDataset(Dataset):
|
|
|
214
220
|
niid: int,
|
|
215
221
|
seed: int = 42,
|
|
216
222
|
):
|
|
223
|
+
# pylint: disable = too-many-arguments, too-many-positional-arguments
|
|
224
|
+
# These arguments are the flat session arrays and the sampling
|
|
225
|
+
# parameters, as for ClozeDataset; they form no group that recurs.
|
|
217
226
|
# The dataset owns its stream, so a seed fixes the negatives it draws
|
|
218
227
|
# rather than leaving them to whatever state the global one is in.
|
|
219
228
|
self.rng = np.random.default_rng(seed)
|
|
220
229
|
self.flat_items = flat_items
|
|
221
230
|
self.window_starts = window_starts
|
|
231
|
+
self.window_ends = window_ends
|
|
222
232
|
self.window_users = window_users
|
|
223
233
|
self.sparse_matrix = sparse_matrix
|
|
224
234
|
self.max_seq_len = max_seq_len
|
|
@@ -233,9 +243,8 @@ class SlidingWindowDataset(Dataset):
|
|
|
233
243
|
start_idx = self.window_starts[idx]
|
|
234
244
|
user_idx = self.window_users[idx]
|
|
235
245
|
|
|
236
|
-
# Clip end to user boundary
|
|
237
|
-
|
|
238
|
-
end_idx = min(start_idx + self.max_seq_len, user_end_limit)
|
|
246
|
+
# Clip end to the user's boundary in the flat array
|
|
247
|
+
end_idx = min(start_idx + self.max_seq_len, self.window_ends[idx])
|
|
239
248
|
|
|
240
249
|
seq_array = self.flat_items[start_idx:end_idx]
|
|
241
250
|
real_len = len(seq_array)
|
|
@@ -11,6 +11,7 @@ from warprec.data.entities.context import build_context_array, context_key
|
|
|
11
11
|
from warprec.data.schema import ColumnLabels, ContextSpec, SignalOptions
|
|
12
12
|
from warprec.data.entities.common import (
|
|
13
13
|
ITEM_INDEX,
|
|
14
|
+
ROW_INDEX,
|
|
14
15
|
USER_INDEX,
|
|
15
16
|
map_to_index_space,
|
|
16
17
|
seeded_dataloader,
|
|
@@ -85,7 +86,7 @@ class Transactions:
|
|
|
85
86
|
# attached to the interaction they describe.
|
|
86
87
|
mapped = map_to_index_space(
|
|
87
88
|
data, self.user_label, self.item_label, user_mapping, item_mapping
|
|
88
|
-
).sort([USER_INDEX, ITEM_INDEX])
|
|
89
|
+
).sort([USER_INDEX, ITEM_INDEX, ROW_INDEX])
|
|
89
90
|
|
|
90
91
|
self._users = mapped.select(USER_INDEX).to_numpy().flatten().astype(np.int64)
|
|
91
92
|
self._items = mapped.select(ITEM_INDEX).to_numpy().flatten().astype(np.int64)
|
|
@@ -226,7 +226,11 @@ class ContextualEvaluationDataset(TorchDataset):
|
|
|
226
226
|
|
|
227
227
|
class SampledEvaluationDataset(TorchDataset):
|
|
228
228
|
"""
|
|
229
|
-
Yields: (user_idx,
|
|
229
|
+
Yields: (user_idx, pos_items_vector, neg_items_vector, pos_values_vector)
|
|
230
|
+
|
|
231
|
+
The values are what the evaluation matrix holds for each positive, the
|
|
232
|
+
rating on explicit data and 1 on implicit data, so a sampled evaluation is
|
|
233
|
+
graded exactly as a full one is.
|
|
230
234
|
"""
|
|
231
235
|
|
|
232
236
|
def __init__(
|
|
@@ -261,6 +265,7 @@ class SampledEvaluationDataset(TorchDataset):
|
|
|
261
265
|
]
|
|
262
266
|
|
|
263
267
|
self.positive_items_list = []
|
|
268
|
+
self.positive_values_list = []
|
|
264
269
|
self.negative_items_list = []
|
|
265
270
|
|
|
266
271
|
# The sampler owns its stream: seeding the global one made the draws
|
|
@@ -275,11 +280,13 @@ class SampledEvaluationDataset(TorchDataset):
|
|
|
275
280
|
drawable = drawable_items(cumulative)
|
|
276
281
|
|
|
277
282
|
for u in self.users_with_eval:
|
|
278
|
-
# Store positives
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
]
|
|
283
|
+
# Store positives, with the relevance full evaluation gives them
|
|
284
|
+
start, end = eval_interactions.indptr[u], eval_interactions.indptr[u + 1]
|
|
285
|
+
eval_pos = eval_interactions.indices[start:end]
|
|
282
286
|
self.positive_items_list.append(torch.tensor(eval_pos, dtype=torch.long))
|
|
287
|
+
self.positive_values_list.append(
|
|
288
|
+
torch.from_numpy(eval_interactions.data[start:end].astype(np.float32))
|
|
289
|
+
)
|
|
283
290
|
|
|
284
291
|
# Compute seen items
|
|
285
292
|
seen_items = self.all_positives[u]
|
|
@@ -307,26 +314,28 @@ class SampledEvaluationDataset(TorchDataset):
|
|
|
307
314
|
def __len__(self) -> int:
|
|
308
315
|
return len(self.users_with_eval)
|
|
309
316
|
|
|
310
|
-
def __getitem__(self, idx: int) -> Tuple[int, Tensor, Tensor]:
|
|
317
|
+
def __getitem__(self, idx: int) -> Tuple[int, Tensor, Tensor, Tensor]:
|
|
311
318
|
user_idx = self.users_with_eval[idx]
|
|
312
319
|
return (
|
|
313
320
|
user_idx,
|
|
314
321
|
self.positive_items_list[idx],
|
|
315
322
|
self.negative_items_list[idx],
|
|
323
|
+
self.positive_values_list[idx],
|
|
316
324
|
)
|
|
317
325
|
|
|
318
326
|
def collate_fn(
|
|
319
|
-
self, batch: List[Tuple[int, Tensor, Tensor]]
|
|
320
|
-
) -> Tuple[Tensor, Tensor, Tensor]:
|
|
327
|
+
self, batch: List[Tuple[int, Tensor, Tensor, Tensor]]
|
|
328
|
+
) -> Tuple[Tensor, Tensor, Tensor, Tensor]:
|
|
321
329
|
"""Collate the sampled evaluation rows into padded batches.
|
|
322
330
|
|
|
323
331
|
Args:
|
|
324
|
-
batch (List[Tuple[int, Tensor, Tensor]]): The rows to collate.
|
|
332
|
+
batch (List[Tuple[int, Tensor, Tensor, Tensor]]): The rows to collate.
|
|
325
333
|
|
|
326
334
|
Returns:
|
|
327
|
-
Tuple[Tensor, Tensor, Tensor]: The users, positives
|
|
335
|
+
Tuple[Tensor, Tensor, Tensor, Tensor]: The users, positives, negatives
|
|
336
|
+
and the values of the positives (0 where a positive is padding).
|
|
328
337
|
"""
|
|
329
|
-
user_indices, positive_tensors, negative_tensors = zip(*batch)
|
|
338
|
+
user_indices, positive_tensors, negative_tensors, value_tensors = zip(*batch)
|
|
330
339
|
user_indices_tensor = torch.tensor(list(user_indices), dtype=torch.long)
|
|
331
340
|
|
|
332
341
|
positives_padded = pad_sequence(
|
|
@@ -339,12 +348,21 @@ class SampledEvaluationDataset(TorchDataset):
|
|
|
339
348
|
batch_first=True,
|
|
340
349
|
padding_value=self.num_items,
|
|
341
350
|
)
|
|
342
|
-
|
|
351
|
+
values_padded = pad_sequence(
|
|
352
|
+
value_tensors, # type: ignore[arg-type]
|
|
353
|
+
batch_first=True,
|
|
354
|
+
padding_value=0.0,
|
|
355
|
+
)
|
|
356
|
+
return user_indices_tensor, positives_padded, negatives_padded, values_padded
|
|
343
357
|
|
|
344
358
|
|
|
345
359
|
class SampledContextualEvaluationDataset(TorchDataset):
|
|
346
360
|
"""
|
|
347
361
|
Yields: (user_idx, pos_item, neg_items_vector, context_vector)
|
|
362
|
+
|
|
363
|
+
Batches carry the value of each positive before the contexts, like the
|
|
364
|
+
non-contextual sampled loader. It is 1: the contextual full evaluation
|
|
365
|
+
scores its target item as 1 too, and the two strategies grade alike.
|
|
348
366
|
"""
|
|
349
367
|
|
|
350
368
|
def __init__(
|
|
@@ -429,15 +447,15 @@ class SampledContextualEvaluationDataset(TorchDataset):
|
|
|
429
447
|
|
|
430
448
|
def collate_fn(
|
|
431
449
|
self, batch: List[Tuple[Tensor, Tensor, Tensor, Tensor]]
|
|
432
|
-
) -> Tuple[Tensor, Tensor, Tensor, Tensor]:
|
|
450
|
+
) -> Tuple[Tensor, Tensor, Tensor, Tensor, Tensor]:
|
|
433
451
|
"""Collate the sampled contextual evaluation rows into batches.
|
|
434
452
|
|
|
435
453
|
Args:
|
|
436
454
|
batch (List[Tuple[Tensor, Tensor, Tensor, Tensor]]): The rows to collate.
|
|
437
455
|
|
|
438
456
|
Returns:
|
|
439
|
-
Tuple[Tensor, Tensor, Tensor, Tensor]: The users, positives,
|
|
440
|
-
and contexts.
|
|
457
|
+
Tuple[Tensor, Tensor, Tensor, Tensor, Tensor]: The users, positives,
|
|
458
|
+
negatives, the values of the positives and the contexts.
|
|
441
459
|
"""
|
|
442
460
|
user_indices, pos_items, neg_items, context_features = zip(*batch)
|
|
443
461
|
|
|
@@ -450,6 +468,7 @@ class SampledContextualEvaluationDataset(TorchDataset):
|
|
|
450
468
|
tensor_user_indices,
|
|
451
469
|
tensor_pos_items,
|
|
452
470
|
tensor_neg_items,
|
|
471
|
+
torch.ones(tensor_pos_items.shape, dtype=torch.float32),
|
|
453
472
|
tensor_context_features,
|
|
454
473
|
)
|
|
455
474
|
|