warprec 2.1.4__tar.gz → 2.1.5__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.5}/PKG-INFO +1 -1
- {warprec-2.1.4 → warprec-2.1.5}/pyproject.toml +1 -1
- {warprec-2.1.4 → warprec-2.1.5}/warprec/common/initialize.py +4 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/data/dataset.py +65 -44
- warprec-2.1.5/warprec/data/ranking.py +376 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/data/splitting/strategies.py +8 -4
- {warprec-2.1.4 → warprec-2.1.5}/warprec/data/writer/azureblob_writer.py +2 -1
- {warprec-2.1.4 → warprec-2.1.5}/warprec/data/writer/base_writer.py +18 -3
- {warprec-2.1.4 → warprec-2.1.5}/warprec/data/writer/local_writer.py +2 -1
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/evaluator.py +2 -2
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/factory.py +1 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/pipelines/design.py +2 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/pipelines/estimate.py +2 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/pipelines/eval.py +3 -1
- {warprec-2.1.4 → warprec-2.1.5}/warprec/pipelines/remotes/data.py +1 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/pipelines/remotes/ml.py +2 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/reranking/base.py +15 -2
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/trainer/objectives.py +3 -0
- {warprec-2.1.4 → warprec-2.1.5}/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.5}/LICENSE +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/README.md +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/common/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/common/run_state.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/common/std_logs.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/data/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/data/entities/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/data/entities/common.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/data/entities/context.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/data/entities/interactions.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/data/entities/knowledge.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/data/entities/multimodal.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/data/entities/sessions.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/data/entities/train_structures/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/data/entities/train_structures/custom_collate_fn.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/data/entities/train_structures/interaction_structures.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/data/entities/train_structures/session_structures.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/data/entities/transactions.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/data/eval_loaders.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/data/filtering.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/data/reader/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/data/reader/azureblob_reader.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/data/reader/base_reader.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/data/reader/local_reader.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/data/schema.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/data/splitting/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/data/splitting/splitter.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/data/writer/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/accuracy/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/accuracy/auc.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/accuracy/f1.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/accuracy/gauc.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/accuracy/hit_rate.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/accuracy/lauc.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/accuracy/logloss.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/accuracy/map.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/accuracy/mar.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/accuracy/mrr.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/accuracy/ndcg.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/accuracy/precision.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/accuracy/recall.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/base_metric.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/bias/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/bias/aclt.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/bias/aplt.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/bias/arp.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/bias/long_tail.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/bias/pop_reo.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/bias/pop_rsp.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/coverage/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/coverage/item_coverage.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/coverage/numretrieved.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/coverage/user_coverage.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/coverage/user_coverage_at_n.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/debiased/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/debiased/base.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/debiased/dcg.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/debiased/recall.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/diversity/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/diversity/gini_index.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/diversity/shannon_entropy.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/diversity/srecall.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/fairness/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/fairness/biasdisparitybd.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/fairness/biasdisparitybr.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/fairness/biasdisparitybs.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/fairness/itemmadranking.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/fairness/itemmadrating.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/fairness/reo.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/fairness/rsp.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/fairness/usermadranking.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/fairness/usermadrating.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/multiobjective/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/multiobjective/euclideandistance.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/multiobjective/hypervolume.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/novelty/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/novelty/efd.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/novelty/epc.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/novelty/novelty_profile.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/rating/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/rating/mae.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/rating/mse.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/metrics/rating/rmse.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/propensity.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/evaluation/statistical_significance.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/pipelines/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/pipelines/common.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/pipelines/remotes/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/pipelines/swarm.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/pipelines/train.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/base_recommender.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/callbacks.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/cdae.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/diffrec.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/ease.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/elsa.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/macridvae.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/multidae.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/multivae.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/sansa.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/graph_based/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/graph_based/dgcf.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/graph_based/egcf.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/graph_based/esigcf.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/graph_based/gcmc.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/graph_based/graph_utils.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightccf.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgcl.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgcn.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgcnpp.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgode.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/graph_based/macrgcn.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/graph_based/mixrec.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/graph_based/ngcf.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/graph_based/paac.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/graph_based/popdcl.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/graph_based/recdcl.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/graph_based/rp3beta.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/graph_based/sgcl.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/graph_based/sgl.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/graph_based/simgcl.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/graph_based/simrec.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/graph_based/ultragcn.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/graph_based/xsimgcl.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/knn/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/knn/itemknn.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/knn/itemknntd.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/knn/userknn.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/knn/userknntd.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/admmslim.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/bpr.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/fism.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/ials.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/ials2008.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/macrmf.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/slim.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/neural/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/neural/convncf.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/neural/neumf.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/collaborative_filtering_recommender/neural/twotower.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/content_based_recommender/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/content_based_recommender/vsm.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/context_aware_recommender/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/context_aware_recommender/afm.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/context_aware_recommender/dcn.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/context_aware_recommender/dcnv2.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/context_aware_recommender/deepfm.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/context_aware_recommender/fm.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/context_aware_recommender/nfm.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/context_aware_recommender/wideanddeep.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/context_aware_recommender/xdeepfm.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/hybrid_recommender/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/hybrid_recommender/addease.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/hybrid_recommender/attributeitemknn.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/hybrid_recommender/attributeuserknn.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/hybrid_recommender/cease.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/knowledge_aware_recommender/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/knowledge_aware_recommender/cke.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/knowledge_aware_recommender/kahfm.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/knowledge_aware_recommender/kgat.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/knowledge_aware_recommender/kgcn.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/knowledge_aware_recommender/kgflex.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/knowledge_aware_recommender/kgin.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/knowledge_aware_recommender/knowledge_utils.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/knowledge_aware_recommender/ripplenet.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/layers.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/losses.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/lr_scheduler_wrapper.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/multimodal_recommender/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/multimodal_recommender/bm3.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/multimodal_recommender/freedom.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/multimodal_recommender/lattice.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/multimodal_recommender/mgcn.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/multimodal_recommender/mmgcn.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/multimodal_recommender/multimodal_utils.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/multimodal_recommender/vbpr.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/optimizer_wrapper.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/proxy.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/reranking/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/reranking/calibration.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/reranking/factory.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/reranking/mmr.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/sequential_recommender/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/sequential_recommender/bert4rec.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/sequential_recommender/bsarec.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/sequential_recommender/caser.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/sequential_recommender/cl4srec.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/sequential_recommender/core.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/sequential_recommender/duorec.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/sequential_recommender/esasrec.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/sequential_recommender/fossil.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/sequential_recommender/gru4rec.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/sequential_recommender/gsasrec.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/sequential_recommender/lightsans.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/sequential_recommender/linrec.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/sequential_recommender/narm.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/sequential_recommender/sasrec.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/sequential_recommender/stan.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/similarities.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/trainer/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/trainer/dashboard_callbacks.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/trainer/logger_callbacks.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/trainer/runtime.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/trainer/scheduler_wrapper.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/trainer/search_algorithm_wrapper.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/trainer/trainer.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/unpersonalized_recommender/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/unpersonalized_recommender/pop.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/recommenders/unpersonalized_recommender/random.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/run.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/serve.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/serving/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/serving/api.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/serving/app.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/serving/catalogue.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/serving/context.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/serving/deployments.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/serving/errors.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/serving/mcp.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/serving/payload.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/serving/schemas.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/serving/servable.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/callback.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/config/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/config/common.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/config/config.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/config/dashboard_configuration.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/config/estimate_configuration.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/config/general_configuration.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/config/model_configuration.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/config/reader_configuration.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/config/recommender_model_config/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/autoencoder_config.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/graph_based_config.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/knn_config.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/latent_factor_config.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/neural_config.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/config/recommender_model_config/content_based_config.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/config/recommender_model_config/context_aware_config.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/config/recommender_model_config/hybrid_config.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/config/recommender_model_config/knowledge_aware_config.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/config/recommender_model_config/multimodal_config.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/config/recommender_model_config/sequential_model_config.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/config/recommender_model_config/unpersonalized_config.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/config/rerank_configuration.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/config/run_configuration.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/config/search_space_wrapper.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/config/serving_configuration.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/config/splitter_configuration.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/config/training_configuration.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/config/writer_configuration.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/enums.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/helpers.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/logger/__init__.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/logger/logger.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/warprec/utils/pause.py +0 -0
- {warprec-2.1.4 → warprec-2.1.5}/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:
|
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
from typing import Any, Dict, Optional, Tuple
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
import torch
|
|
5
|
+
from scipy.sparse import csr_matrix
|
|
6
|
+
from torch import Tensor
|
|
7
|
+
|
|
8
|
+
from warprec.data.entities.context import context_key
|
|
9
|
+
from warprec.utils.logger import logger
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def mask_seen_pairs(predictions: Tensor, seen: csr_matrix) -> None:
|
|
13
|
+
"""Exclude from the ranking every item a user has already interacted with.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
predictions (Tensor): The score matrix, modified in place.
|
|
17
|
+
seen (csr_matrix): The rows of the training matrix for this batch of users.
|
|
18
|
+
"""
|
|
19
|
+
predictions[seen.nonzero()] = -torch.inf
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def mask_seen_in_context(
|
|
23
|
+
predictions: Tensor,
|
|
24
|
+
user_indices: Tensor,
|
|
25
|
+
context_rows: np.ndarray,
|
|
26
|
+
context_index: Dict[Tuple[int, int], np.ndarray],
|
|
27
|
+
context_ids: Dict[tuple, int],
|
|
28
|
+
target_items: Optional[Tensor] = None,
|
|
29
|
+
) -> int:
|
|
30
|
+
"""Exclude the items a user has seen *in this situation*, rather than at all.
|
|
31
|
+
|
|
32
|
+
A context-aware run asks a different question of the training history: an item
|
|
33
|
+
the user watched on a weekday morning is a fair recommendation for a Saturday
|
|
34
|
+
night. A row whose context never appeared in training has nothing to exclude.
|
|
35
|
+
|
|
36
|
+
Args:
|
|
37
|
+
predictions (Tensor): The score matrix, modified in place.
|
|
38
|
+
user_indices (Tensor): The users of this batch.
|
|
39
|
+
context_rows (np.ndarray): The context of each row of the batch.
|
|
40
|
+
context_index (Dict[Tuple[int, int], np.ndarray]): The items each user saw,
|
|
41
|
+
per context id.
|
|
42
|
+
context_ids (Dict[tuple, int]): The id of each known context vector.
|
|
43
|
+
target_items (Optional[Tensor]): The ground-truth item of each row, when the
|
|
44
|
+
evaluation has one. Used only to count how often the answer was a
|
|
45
|
+
repetition the run has just masked away.
|
|
46
|
+
|
|
47
|
+
Returns:
|
|
48
|
+
int: How many rows had their ground-truth item masked as already seen.
|
|
49
|
+
"""
|
|
50
|
+
repeated = 0
|
|
51
|
+
for row, user in enumerate(user_indices.tolist()):
|
|
52
|
+
key = context_ids.get(context_key(context_rows[row]), -1)
|
|
53
|
+
if key < 0:
|
|
54
|
+
continue
|
|
55
|
+
|
|
56
|
+
seen = context_index.get((user, key))
|
|
57
|
+
if seen is None:
|
|
58
|
+
continue
|
|
59
|
+
|
|
60
|
+
predictions[row, seen] = -torch.inf
|
|
61
|
+
if target_items is not None:
|
|
62
|
+
repeated += int(int(target_items[row]) in seen)
|
|
63
|
+
|
|
64
|
+
return repeated
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def resolve_recommendation_mask(policy: str, transactions: Any) -> str:
|
|
68
|
+
"""Which seen-item rule the written recommendations can follow.
|
|
69
|
+
|
|
70
|
+
Evaluation asks a question about a moment: this user, in this situation, was
|
|
71
|
+
shown this item. Writing recommendations asks a question about a user alone,
|
|
72
|
+
so there is no situation to compare a history against and a contextual policy
|
|
73
|
+
has nothing to resolve. It falls back to excluding everything the user has
|
|
74
|
+
seen, which is the conservative reading, and says so rather than leaving the
|
|
75
|
+
written list quietly filtered by a rule the configuration did not ask for.
|
|
76
|
+
|
|
77
|
+
'none' and 'pair' mean the same here as they do in evaluation, so a run that
|
|
78
|
+
asks for either gets it.
|
|
79
|
+
|
|
80
|
+
Args:
|
|
81
|
+
policy (str): The configured policy, one of 'auto', 'context', 'pair' or
|
|
82
|
+
'none'.
|
|
83
|
+
transactions (Any): The row-oriented training records, or None when the
|
|
84
|
+
dataset has no contextual columns.
|
|
85
|
+
|
|
86
|
+
Returns:
|
|
87
|
+
str: The rule to apply, either 'pair' or 'none'.
|
|
88
|
+
"""
|
|
89
|
+
resolved = resolve_mask_policy(policy, transactions)
|
|
90
|
+
if resolved != "context":
|
|
91
|
+
return resolved
|
|
92
|
+
|
|
93
|
+
logger.attention(
|
|
94
|
+
"Recommendations are written for a user rather than for a user in a "
|
|
95
|
+
"situation, so the contextual seen-item rule cannot be applied to them. "
|
|
96
|
+
"Every item the user has already interacted with is excluded instead."
|
|
97
|
+
)
|
|
98
|
+
return "pair"
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def resolve_mask_policy(policy: str, transactions: Any) -> str:
|
|
102
|
+
"""Decide which seen-item rule a run follows.
|
|
103
|
+
|
|
104
|
+
Args:
|
|
105
|
+
policy (str): The configured policy, one of 'auto', 'context', 'pair' or
|
|
106
|
+
'none'.
|
|
107
|
+
transactions (Any): The row-oriented training records, or None when the
|
|
108
|
+
dataset has no contextual columns.
|
|
109
|
+
|
|
110
|
+
Returns:
|
|
111
|
+
str: The resolved policy, never 'auto'.
|
|
112
|
+
"""
|
|
113
|
+
if policy != "auto":
|
|
114
|
+
return policy
|
|
115
|
+
return (
|
|
116
|
+
"context"
|
|
117
|
+
if transactions is not None and transactions.context_labels
|
|
118
|
+
else "pair"
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def cold_item_candidates(train_set: csr_matrix, candidates: str) -> Optional[Tensor]:
|
|
123
|
+
"""Which items a run is allowed to rank, under a cold-start protocol.
|
|
124
|
+
|
|
125
|
+
An item nobody interacted with during training is a cold one. Ranking over the
|
|
126
|
+
whole catalogue mixes the two populations, and since the warm items are both
|
|
127
|
+
far more numerous and far better served by a collaborative model, a cold-start
|
|
128
|
+
result computed over everything mostly measures warm-item ranking instead.
|
|
129
|
+
|
|
130
|
+
Args:
|
|
131
|
+
train_set (csr_matrix): The training interaction matrix.
|
|
132
|
+
candidates (str): Which population to keep, 'all', 'cold' or 'warm'.
|
|
133
|
+
|
|
134
|
+
Returns:
|
|
135
|
+
Optional[Tensor]: A boolean mask over the items, or None when every item
|
|
136
|
+
is eligible and there is nothing to restrict.
|
|
137
|
+
|
|
138
|
+
Raises:
|
|
139
|
+
ValueError: If the candidate set is not one WarpRec knows.
|
|
140
|
+
"""
|
|
141
|
+
if candidates == "all":
|
|
142
|
+
return None
|
|
143
|
+
|
|
144
|
+
if candidates not in ("cold", "warm"):
|
|
145
|
+
raise ValueError(
|
|
146
|
+
f"Candidate set '{candidates}' is not supported. "
|
|
147
|
+
"Use 'all', 'cold' or 'warm'."
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
is_cold = torch.as_tensor(train_set.getnnz(axis=0) == 0)
|
|
151
|
+
return is_cold if candidates == "cold" else ~is_cold
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def restrict_to_candidates(predictions: Tensor, candidates: Tensor) -> None:
|
|
155
|
+
"""Exclude from the ranking every item outside the candidate set.
|
|
156
|
+
|
|
157
|
+
Args:
|
|
158
|
+
predictions (Tensor): The score matrix, modified in place.
|
|
159
|
+
candidates (Tensor): A boolean mask over the items, True to keep.
|
|
160
|
+
"""
|
|
161
|
+
predictions[:, ~candidates] = -torch.inf
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
# Constants of MurmurHash3's 32-bit finaliser and of Fibonacci hashing, as the
|
|
165
|
+
# signed 32-bit integers torch computes with.
|
|
166
|
+
_FMIX_1 = 0x85EBCA6B - 2**32
|
|
167
|
+
_FMIX_2 = 0xC2B2AE35 - 2**32
|
|
168
|
+
_GOLDEN = 0x9E3779B1 - 2**32
|
|
169
|
+
_KEY_BITS = 30
|
|
170
|
+
|
|
171
|
+
# How many scores a tie break keys at a time, which bounds its memory whatever
|
|
172
|
+
# the batch and the catalogue.
|
|
173
|
+
_CHUNK = 2**23
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def _fmix32_(x: Tensor) -> Tensor:
|
|
177
|
+
"""Scramble 32-bit integers in place with MurmurHash3's finaliser.
|
|
178
|
+
|
|
179
|
+
A bijection in which every input bit reaches every output bit, so inputs
|
|
180
|
+
that differ in one bit come out unrelated. Shifts are logical: torch shifts
|
|
181
|
+
signed integers arithmetically, so the sign copies are masked away.
|
|
182
|
+
|
|
183
|
+
Args:
|
|
184
|
+
x (Tensor): An int32 tensor, overwritten.
|
|
185
|
+
|
|
186
|
+
Returns:
|
|
187
|
+
Tensor: The same tensor, scrambled.
|
|
188
|
+
"""
|
|
189
|
+
shifted = torch.empty_like(x)
|
|
190
|
+
for shift, multiplier in ((16, _FMIX_1), (13, _FMIX_2), (16, None)):
|
|
191
|
+
torch.bitwise_right_shift(x, shift, out=shifted)
|
|
192
|
+
shifted.bitwise_and_((1 << (32 - shift)) - 1)
|
|
193
|
+
x.bitwise_xor_(shifted)
|
|
194
|
+
if multiplier is not None:
|
|
195
|
+
x.mul_(multiplier)
|
|
196
|
+
return x
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def _tie_keys(seed: int, users: Tensor, items: Tensor) -> Tensor:
|
|
200
|
+
"""The random key of every (user, item) pair, a pure function of the three.
|
|
201
|
+
|
|
202
|
+
Being a function of the pair rather than a draw from a stream, a user's key
|
|
203
|
+
for an item does not depend on which other users share the batch, how many
|
|
204
|
+
of them are ambiguous, or what was ranked before. So the evaluator and the
|
|
205
|
+
writer, which walk the users in different batches, rank them alike.
|
|
206
|
+
|
|
207
|
+
Args:
|
|
208
|
+
seed (int): The seed of the tie break.
|
|
209
|
+
users (Tensor): The user of each row.
|
|
210
|
+
items (Tensor): The item of each column.
|
|
211
|
+
|
|
212
|
+
Returns:
|
|
213
|
+
Tensor: Non-negative int32 keys below 2**30, [rows, columns].
|
|
214
|
+
"""
|
|
215
|
+
folded = (seed ^ (seed >> 32)) & 0xFFFFFFFF
|
|
216
|
+
folded = folded - 2**32 if folded >= 2**31 else folded
|
|
217
|
+
|
|
218
|
+
user_part = users.to(torch.int32, copy=True).mul_(_GOLDEN).bitwise_xor_(folded)
|
|
219
|
+
user_part = _fmix32_(_fmix32_(user_part))
|
|
220
|
+
item_part = _fmix32_(items.to(torch.int32, copy=True).mul_(_GOLDEN).add_(1))
|
|
221
|
+
|
|
222
|
+
keys = _fmix32_(user_part.unsqueeze(1) ^ item_part.unsqueeze(0))
|
|
223
|
+
return keys.bitwise_right_shift_(32 - _KEY_BITS).bitwise_and_((1 << _KEY_BITS) - 1)
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
def top_k_breaking_ties(
|
|
227
|
+
predictions: Tensor,
|
|
228
|
+
k: int,
|
|
229
|
+
generator: Optional[torch.Generator] = None,
|
|
230
|
+
user_indices: Optional[Tensor] = None,
|
|
231
|
+
) -> Tuple[Tensor, Tensor]:
|
|
232
|
+
"""Take the top k scores, deciding ties by chance rather than by item id.
|
|
233
|
+
|
|
234
|
+
``torch.topk`` makes no promise about the order of equal scores, and what it
|
|
235
|
+
does is not a neutral rule: the choice follows the item indices, so a model
|
|
236
|
+
that scores a whole population alike returns the same items to every user,
|
|
237
|
+
picked by their position in the catalogue (often the lowest ids, which in
|
|
238
|
+
most catalogues are the oldest and best known entries).
|
|
239
|
+
Under a cold-start protocol that is the difference between a model that has
|
|
240
|
+
learned nothing scoring at the random floor and appearing to beat it.
|
|
241
|
+
|
|
242
|
+
Every user's ties are drawn on their own: each item of an ambiguous row gets a
|
|
243
|
+
random key, and the row is ranked by its score first and by that key among
|
|
244
|
+
equal scores. So a model that ties a whole population gives each user an
|
|
245
|
+
independent uniform draw of it, in a uniformly random order, and its score is
|
|
246
|
+
an average over the users rather than the luck of one draw shared by a batch.
|
|
247
|
+
A higher score still always ranks above a lower one.
|
|
248
|
+
|
|
249
|
+
The key is a hash of the generator's seed, the user and the item, not a draw
|
|
250
|
+
from the generator's stream, so a user's ranking is the same whichever batch
|
|
251
|
+
they are ranked in: the lists a run writes are the lists it evaluated.
|
|
252
|
+
|
|
253
|
+
Only the rows whose ranking is genuinely ambiguous get keys, and a row with no
|
|
254
|
+
ties comes back exactly as ``torch.topk`` returns it. Finding them costs one
|
|
255
|
+
position past the cutoff; on real model scores almost no row is ambiguous.
|
|
256
|
+
|
|
257
|
+
Args:
|
|
258
|
+
predictions (Tensor): The score matrix, one row per user and one column
|
|
259
|
+
per item.
|
|
260
|
+
k (int): The cutoff.
|
|
261
|
+
generator (Optional[torch.Generator]): The generator whose seed
|
|
262
|
+
(``initial_seed``) makes the draw reproducible; its stream is not
|
|
263
|
+
consumed. Without one the ordering falls back to the deterministic
|
|
264
|
+
behaviour of ``torch.topk``.
|
|
265
|
+
user_indices (Optional[Tensor]): The user of each row. Without them the
|
|
266
|
+
rows are numbered from zero, so a user's draw then depends on their
|
|
267
|
+
position in the batch.
|
|
268
|
+
|
|
269
|
+
Returns:
|
|
270
|
+
Tuple[Tensor, Tensor]: The top-k values, in descending order, and the
|
|
271
|
+
item indices they belong to.
|
|
272
|
+
"""
|
|
273
|
+
if generator is None:
|
|
274
|
+
return torch.topk(predictions, k, dim=1)
|
|
275
|
+
|
|
276
|
+
# One extra position past the cutoff is enough to find the rows that need a
|
|
277
|
+
# draw: a row with no two equal scores among them has both its membership
|
|
278
|
+
# and its order already settled.
|
|
279
|
+
probe = min(k + 1, predictions.size(1))
|
|
280
|
+
values, indices = torch.topk(predictions, probe, dim=1)
|
|
281
|
+
|
|
282
|
+
ambiguous = (values[:, :-1] == values[:, 1:]).any(dim=1)
|
|
283
|
+
values, indices = values[:, :k], indices[:, :k]
|
|
284
|
+
if not bool(ambiguous.any()):
|
|
285
|
+
return values, indices
|
|
286
|
+
|
|
287
|
+
seed = generator.initial_seed()
|
|
288
|
+
device = predictions.device
|
|
289
|
+
rows = ambiguous.nonzero(as_tuple=True)[0]
|
|
290
|
+
users = user_indices.to(device)[rows] if user_indices is not None else rows
|
|
291
|
+
values, indices = values.clone(), indices.clone()
|
|
292
|
+
|
|
293
|
+
step = max(1, _CHUNK // predictions.size(1))
|
|
294
|
+
for start in range(0, rows.numel(), step):
|
|
295
|
+
part = rows[start : start + step]
|
|
296
|
+
scores = predictions[part]
|
|
297
|
+
|
|
298
|
+
# The k-th score splits each row in three: the items above it are in
|
|
299
|
+
# the list whatever the draw, the items below it are out, and the items
|
|
300
|
+
# equal to it compete for the places left.
|
|
301
|
+
kth = values[part, k - 1 :]
|
|
302
|
+
|
|
303
|
+
# Keys are only worth computing for the items that can still make some
|
|
304
|
+
# list. When the ties sit on a known population, such as the cold items
|
|
305
|
+
# of a cold-start run, that is a small fraction of the catalogue.
|
|
306
|
+
columns = (scores >= kth).any(dim=0).nonzero(as_tuple=True)[0]
|
|
307
|
+
if columns.numel() <= scores.size(1) // 2:
|
|
308
|
+
scores = scores[:, columns]
|
|
309
|
+
else:
|
|
310
|
+
columns = torch.arange(scores.size(1), device=device)
|
|
311
|
+
|
|
312
|
+
# Keying the items above the k-th score over every random key, and the
|
|
313
|
+
# ones below it under, lets one top-k make the choice for every row at
|
|
314
|
+
# once.
|
|
315
|
+
keys = _tie_keys(seed, users[start : start + step], columns)
|
|
316
|
+
keys.masked_fill_(scores < kth, -1)
|
|
317
|
+
keys[scores > kth] += 1 << _KEY_BITS
|
|
318
|
+
_, chosen = torch.topk(keys, k, dim=1)
|
|
319
|
+
del keys
|
|
320
|
+
|
|
321
|
+
# The draw settled which items are in, and in key order. Sorting them
|
|
322
|
+
# by score, stably, puts a higher score first and leaves equal scores in
|
|
323
|
+
# the order their keys drew.
|
|
324
|
+
tied_values, order = torch.sort(
|
|
325
|
+
scores.gather(1, chosen), dim=1, descending=True, stable=True
|
|
326
|
+
)
|
|
327
|
+
values[part] = tied_values
|
|
328
|
+
indices[part] = columns[chosen.gather(1, order)]
|
|
329
|
+
|
|
330
|
+
return values, indices
|
|
331
|
+
|
|
332
|
+
rows = ambiguous.nonzero(as_tuple=True)[0]
|
|
333
|
+
scores = predictions if rows.numel() == predictions.size(0) else predictions[rows]
|
|
334
|
+
|
|
335
|
+
# The k-th score splits each row in three: the items above it are in the
|
|
336
|
+
# list whatever the draw, the items below it are out, and the items equal to
|
|
337
|
+
# it compete for the places left.
|
|
338
|
+
kth = values[rows, k - 1 :]
|
|
339
|
+
|
|
340
|
+
# Drawing the keys is the dominant cost, so they are drawn only for the
|
|
341
|
+
# items that can still make some list. When the ties sit on a known
|
|
342
|
+
# population, such as the cold items of a cold-start run, that is a small
|
|
343
|
+
# fraction of the catalogue. When it is most of it, narrowing would only
|
|
344
|
+
# add a copy of the scores.
|
|
345
|
+
columns = (scores >= kth).any(dim=0).nonzero(as_tuple=True)[0]
|
|
346
|
+
narrowed = columns.numel() <= scores.size(1) // 2
|
|
347
|
+
if narrowed:
|
|
348
|
+
scores = scores[:, columns]
|
|
349
|
+
|
|
350
|
+
# Keying the items above the k-th score over every random key, and the ones
|
|
351
|
+
# below it under, lets one top-k make the choice for every row at once, with
|
|
352
|
+
# a fresh key per user and item. Drawn where the generator lives, which
|
|
353
|
+
# torch requires, then moved to the scores: the evaluator's generator is on
|
|
354
|
+
# the CPU even when the scores are not.
|
|
355
|
+
keys = torch.rand(scores.shape, generator=generator, device=generator.device).to(
|
|
356
|
+
predictions.device
|
|
357
|
+
)
|
|
358
|
+
keys.masked_fill_(scores < kth, -1.0)
|
|
359
|
+
keys[scores > kth] += 2.0
|
|
360
|
+
_, chosen = torch.topk(keys, k, dim=1)
|
|
361
|
+
del keys
|
|
362
|
+
|
|
363
|
+
# The draw settled which items are in, and in key order. Sorting them by
|
|
364
|
+
# score, stably, puts a higher score first and leaves equal scores in the
|
|
365
|
+
# order their keys drew.
|
|
366
|
+
tied_values, order = torch.sort(
|
|
367
|
+
scores.gather(1, chosen), dim=1, descending=True, stable=True
|
|
368
|
+
)
|
|
369
|
+
chosen = chosen.gather(1, order)
|
|
370
|
+
if narrowed:
|
|
371
|
+
chosen = columns[chosen]
|
|
372
|
+
|
|
373
|
+
values, indices = values.clone(), indices.clone()
|
|
374
|
+
values[rows] = tied_values
|
|
375
|
+
indices[rows] = chosen
|
|
376
|
+
return values, indices
|
|
@@ -359,8 +359,10 @@ class RandomHoldoutSplit(SplittingStrategy):
|
|
|
359
359
|
|
|
360
360
|
# Random sampling
|
|
361
361
|
n_rows = data_prep.select(nw.col(data_prep.columns[0])).shape[0]
|
|
362
|
-
np.random
|
|
363
|
-
|
|
362
|
+
# A generator of its own, so that the user's np.random stream is left
|
|
363
|
+
# where it was. RandomState with the same seed draws exactly what the
|
|
364
|
+
# seeded global stream used to, so every split is unchanged.
|
|
365
|
+
random_vals = np.random.RandomState(seed).rand(n_rows)
|
|
364
366
|
|
|
365
367
|
# Assign the random values
|
|
366
368
|
rand_series = nw.new_series(
|
|
@@ -425,8 +427,10 @@ class RandomLeaveKOutSplit(SplittingStrategy):
|
|
|
425
427
|
|
|
426
428
|
# Random sampling
|
|
427
429
|
n_rows = data_prep.select(nw.col(data_prep.columns[0])).shape[0]
|
|
428
|
-
np.random
|
|
429
|
-
|
|
430
|
+
# A generator of its own, so that the user's np.random stream is left
|
|
431
|
+
# where it was. RandomState with the same seed draws exactly what the
|
|
432
|
+
# seeded global stream used to, so every split is unchanged.
|
|
433
|
+
random_vals = np.random.RandomState(seed).rand(n_rows)
|
|
430
434
|
|
|
431
435
|
# Assign the random values
|
|
432
436
|
rand_series = nw.new_series(
|
|
@@ -91,6 +91,7 @@ class AzureBlobWriter(Writer):
|
|
|
91
91
|
rating_label: str = "rating",
|
|
92
92
|
reranker: Optional[Any] = None,
|
|
93
93
|
mask_seen: str = "pair",
|
|
94
|
+
seed: int = 42,
|
|
94
95
|
) -> None:
|
|
95
96
|
"""Uploads recommendations to Azure Blob Storage in a streaming fashion."""
|
|
96
97
|
self._refuse_contextual_recommendations(model)
|
|
@@ -103,7 +104,7 @@ class AzureBlobWriter(Writer):
|
|
|
103
104
|
|
|
104
105
|
# Get the generator that yields batches of recommendation rows
|
|
105
106
|
batch_generator = self._generate_recommendation_batches(
|
|
106
|
-
model, dataset, k, reranker, mask_seen
|
|
107
|
+
model, dataset, k, reranker, mask_seen, seed
|
|
107
108
|
)
|
|
108
109
|
|
|
109
110
|
def csv_batch_generator() -> Generator[bytes, None, None]:
|