warprec 2.1.7__tar.gz → 2.1.8__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.7 → warprec-2.1.8}/PKG-INFO +1 -1
- {warprec-2.1.7 → warprec-2.1.8}/pyproject.toml +1 -1
- {warprec-2.1.7 → warprec-2.1.8}/warprec/data/dataset.py +5 -0
- warprec-2.1.8/warprec/data/stash.py +69 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/evaluator.py +43 -2
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/accuracy/auc.py +1 -1
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/accuracy/f1.py +1 -2
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/accuracy/gauc.py +2 -2
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/accuracy/ndcg.py +3 -6
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/base_metric.py +80 -15
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/coverage/item_coverage.py +1 -1
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/coverage/user_coverage.py +1 -1
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/coverage/user_coverage_at_n.py +6 -2
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/debiased/base.py +4 -11
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/diversity/gini_index.py +1 -1
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/diversity/shannon_entropy.py +1 -1
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/fairness/biasdisparitybd.py +1 -1
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/fairness/biasdisparitybs.py +5 -1
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/fairness/itemmadranking.py +2 -2
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/fairness/itemmadrating.py +6 -3
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/fairness/usermadranking.py +5 -8
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/fairness/usermadrating.py +2 -2
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/multiobjective/euclideandistance.py +1 -1
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/multiobjective/hypervolume.py +1 -1
- {warprec-2.1.7 → warprec-2.1.8}/warprec/pipelines/design.py +2 -1
- {warprec-2.1.7 → warprec-2.1.8}/warprec/pipelines/estimate.py +3 -2
- {warprec-2.1.7 → warprec-2.1.8}/warprec/pipelines/eval.py +2 -1
- {warprec-2.1.7 → warprec-2.1.8}/warprec/pipelines/remotes/ml.py +2 -1
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/base_recommender.py +51 -11
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/cdae.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/diffrec.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/elsa.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/macridvae.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/multidae.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/multivae.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/dgcf.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/egcf.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/esigcf.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/gcmc.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightccf.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgcl.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgcn.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgcnpp.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgode.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/macrgcn.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/mixrec.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/ngcf.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/paac.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/popdcl.py +0 -7
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/recdcl.py +0 -6
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/sgcl.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/sgl.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/simgcl.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/simrec.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/ultragcn.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/xsimgcl.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/bpr.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/fism.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/macrmf.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/neural/convncf.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/neural/neumf.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/neural/twotower.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/context_aware_recommender/afm.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/context_aware_recommender/dcn.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/context_aware_recommender/dcnv2.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/context_aware_recommender/deepfm.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/context_aware_recommender/fm.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/context_aware_recommender/nfm.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/context_aware_recommender/wideanddeep.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/context_aware_recommender/xdeepfm.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/knowledge_aware_recommender/cke.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/knowledge_aware_recommender/kahfm.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/knowledge_aware_recommender/kgat.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/knowledge_aware_recommender/kgcn.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/knowledge_aware_recommender/kgflex.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/knowledge_aware_recommender/kgin.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/knowledge_aware_recommender/ripplenet.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/multimodal_recommender/bm3.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/multimodal_recommender/freedom.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/multimodal_recommender/lattice.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/multimodal_recommender/mgcn.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/multimodal_recommender/mmgcn.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/multimodal_recommender/vbpr.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/sequential_recommender/bert4rec.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/sequential_recommender/bsarec.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/sequential_recommender/caser.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/sequential_recommender/cl4srec.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/sequential_recommender/core.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/sequential_recommender/duorec.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/sequential_recommender/esasrec.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/sequential_recommender/fossil.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/sequential_recommender/gru4rec.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/sequential_recommender/gsasrec.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/sequential_recommender/lightsans.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/sequential_recommender/linrec.py +0 -4
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/sequential_recommender/narm.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/sequential_recommender/sasrec.py +0 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/trainer/objectives.py +2 -1
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/trainer/trainer.py +3 -2
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/__init__.py +0 -2
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/config/model_configuration.py +26 -5
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/enums.py +0 -102
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/helpers.py +36 -2
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/registry.py +48 -0
- {warprec-2.1.7 → warprec-2.1.8}/LICENSE +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/README.md +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/common/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/common/initialize.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/common/run_state.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/common/std_logs.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/data/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/data/entities/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/data/entities/common.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/data/entities/context.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/data/entities/interactions.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/data/entities/knowledge.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/data/entities/multimodal.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/data/entities/sessions.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/data/entities/train_structures/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/data/entities/train_structures/custom_collate_fn.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/data/entities/train_structures/interaction_structures.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/data/entities/train_structures/session_structures.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/data/entities/transactions.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/data/eval_loaders.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/data/filtering.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/data/ranking.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/data/reader/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/data/reader/azureblob_reader.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/data/reader/base_reader.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/data/reader/local_reader.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/data/schema.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/data/splitting/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/data/splitting/splitter.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/data/splitting/strategies.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/data/writer/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/data/writer/azureblob_writer.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/data/writer/base_writer.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/data/writer/local_writer.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/factory.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/accuracy/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/accuracy/hit_rate.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/accuracy/lauc.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/accuracy/logloss.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/accuracy/map.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/accuracy/mar.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/accuracy/mrr.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/accuracy/precision.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/accuracy/recall.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/bias/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/bias/aclt.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/bias/aplt.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/bias/arp.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/bias/long_tail.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/bias/pop_reo.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/bias/pop_rsp.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/coverage/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/coverage/numretrieved.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/debiased/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/debiased/dcg.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/debiased/recall.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/diversity/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/diversity/srecall.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/fairness/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/fairness/biasdisparitybr.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/fairness/reo.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/fairness/rsp.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/multiobjective/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/novelty/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/novelty/efd.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/novelty/epc.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/novelty/novelty_profile.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/rating/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/rating/mae.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/rating/mse.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/rating/rmse.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/propensity.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/statistical_significance.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/pipelines/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/pipelines/common.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/pipelines/remotes/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/pipelines/remotes/data.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/pipelines/swarm.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/pipelines/train.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/callbacks.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/ease.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/sansa.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/graph_utils.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/rp3beta.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/knn/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/knn/itemknn.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/knn/itemknntd.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/knn/userknn.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/knn/userknntd.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/admmslim.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/ials.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/ials2008.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/slim.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/collaborative_filtering_recommender/neural/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/content_based_recommender/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/content_based_recommender/vsm.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/context_aware_recommender/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/hybrid_recommender/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/hybrid_recommender/addease.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/hybrid_recommender/attributeitemknn.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/hybrid_recommender/attributeuserknn.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/hybrid_recommender/cease.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/knowledge_aware_recommender/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/knowledge_aware_recommender/knowledge_utils.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/layers.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/losses.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/lr_scheduler_wrapper.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/multimodal_recommender/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/multimodal_recommender/multimodal_utils.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/optimizer_wrapper.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/proxy.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/reranking/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/reranking/base.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/reranking/calibration.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/reranking/factory.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/reranking/mmr.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/sequential_recommender/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/sequential_recommender/stan.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/similarities.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/trainer/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/trainer/dashboard_callbacks.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/trainer/logger_callbacks.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/trainer/runtime.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/trainer/scheduler_wrapper.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/trainer/search_algorithm_wrapper.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/unpersonalized_recommender/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/unpersonalized_recommender/pop.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/recommenders/unpersonalized_recommender/random.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/run.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/serve.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/serving/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/serving/api.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/serving/app.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/serving/catalogue.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/serving/context.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/serving/deployments.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/serving/errors.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/serving/mcp.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/serving/payload.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/serving/schemas.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/serving/servable.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/callback.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/config/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/config/common.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/config/config.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/config/dashboard_configuration.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/config/estimate_configuration.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/config/evaluation_configuration.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/config/general_configuration.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/config/reader_configuration.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/config/recommender_model_config/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/autoencoder_config.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/graph_based_config.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/knn_config.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/latent_factor_config.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/neural_config.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/config/recommender_model_config/content_based_config.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/config/recommender_model_config/context_aware_config.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/config/recommender_model_config/hybrid_config.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/config/recommender_model_config/knowledge_aware_config.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/config/recommender_model_config/multimodal_config.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/config/recommender_model_config/sequential_model_config.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/config/recommender_model_config/unpersonalized_config.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/config/rerank_configuration.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/config/run_configuration.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/config/search_space_wrapper.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/config/serving_configuration.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/config/splitter_configuration.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/config/training_configuration.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/config/writer_configuration.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/logger/__init__.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/logger/logger.py +0 -0
- {warprec-2.1.7 → warprec-2.1.8}/warprec/utils/pause.py +0 -0
|
@@ -20,6 +20,7 @@ from warprec.data.entities import (
|
|
|
20
20
|
Sessions,
|
|
21
21
|
Transactions,
|
|
22
22
|
)
|
|
23
|
+
from warprec.data.stash import METRIC_ARGUMENTS, MODEL_ARGUMENTS, check_stash
|
|
23
24
|
from warprec.data.schema import ColumnLabels, ContextSpec, SideData, SignalOptions
|
|
24
25
|
from warprec.data.eval_loaders import (
|
|
25
26
|
EvaluationDataset,
|
|
@@ -1366,10 +1367,14 @@ class Dataset:
|
|
|
1366
1367
|
def add_to_stash(self, key: str, value: Any):
|
|
1367
1368
|
"""Add a custom structure to the stash.
|
|
1368
1369
|
|
|
1370
|
+
The stash is passed to every model and every metric next to the
|
|
1371
|
+
arguments WarpRec gives them, so those names cannot be used.
|
|
1372
|
+
|
|
1369
1373
|
Args:
|
|
1370
1374
|
key (str): The key of the custom structure.
|
|
1371
1375
|
value (Any): The value of the custom structure.
|
|
1372
1376
|
"""
|
|
1377
|
+
check_stash({key: value}, MODEL_ARGUMENTS | METRIC_ARGUMENTS, "model or metric")
|
|
1373
1378
|
self._stash[key] = value
|
|
1374
1379
|
|
|
1375
1380
|
def update_mappings(self, user_mapping: dict, item_mapping: dict):
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
from typing import Any, Dict, FrozenSet, Iterable
|
|
2
|
+
|
|
3
|
+
# The keyword arguments WarpRec passes to every model it builds, restores or
|
|
4
|
+
# estimates, next to the stash.
|
|
5
|
+
MODEL_ARGUMENTS: FrozenSet[str] = frozenset(
|
|
6
|
+
{
|
|
7
|
+
"name",
|
|
8
|
+
"params",
|
|
9
|
+
"info",
|
|
10
|
+
"interactions",
|
|
11
|
+
"transactions",
|
|
12
|
+
"knowledge",
|
|
13
|
+
"multimodal",
|
|
14
|
+
"sessions",
|
|
15
|
+
"seed",
|
|
16
|
+
"block_size",
|
|
17
|
+
"chunk_size",
|
|
18
|
+
"checkpoint",
|
|
19
|
+
"strict",
|
|
20
|
+
}
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
# The keyword arguments the evaluator passes to every metric, next to the stash.
|
|
24
|
+
METRIC_ARGUMENTS: FrozenSet[str] = frozenset(
|
|
25
|
+
{
|
|
26
|
+
"k",
|
|
27
|
+
"num_users",
|
|
28
|
+
"num_items",
|
|
29
|
+
"item_interactions",
|
|
30
|
+
"item_indices",
|
|
31
|
+
"train_matrix",
|
|
32
|
+
"feature_lookup",
|
|
33
|
+
"user_cluster",
|
|
34
|
+
"item_cluster",
|
|
35
|
+
"propensity",
|
|
36
|
+
}
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def check_stash(
|
|
41
|
+
stash: Dict[str, Any], reserved: Iterable[str], receiver: str
|
|
42
|
+
) -> Dict[str, Any]:
|
|
43
|
+
"""Refuse a stash entry named like an argument WarpRec passes itself.
|
|
44
|
+
|
|
45
|
+
The stash is passed as keyword arguments next to WarpRec's own, so an entry
|
|
46
|
+
with one of their names would replace it, or make the call fail with a
|
|
47
|
+
message that does not mention the stash.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
stash (Dict[str, Any]): The stash.
|
|
51
|
+
reserved (Iterable[str]): The arguments WarpRec passes to the receiver.
|
|
52
|
+
receiver (str): What the stash is passed to, e.g. 'model' or 'metric'.
|
|
53
|
+
|
|
54
|
+
Returns:
|
|
55
|
+
Dict[str, Any]: The stash, unchanged.
|
|
56
|
+
|
|
57
|
+
Raises:
|
|
58
|
+
ValueError: If a stash entry has the name of a reserved argument.
|
|
59
|
+
"""
|
|
60
|
+
reserved = set(reserved)
|
|
61
|
+
taken = sorted(key for key in stash if key in reserved)
|
|
62
|
+
if taken:
|
|
63
|
+
raise ValueError(
|
|
64
|
+
f"The stash entry {', '.join(repr(key) for key in taken)} has the "
|
|
65
|
+
f"name of an argument WarpRec passes to every {receiver} itself, so "
|
|
66
|
+
"one would replace the other. Rename the entry; the names WarpRec "
|
|
67
|
+
f"uses are {sorted(reserved)}."
|
|
68
|
+
)
|
|
69
|
+
return stash
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import time
|
|
2
2
|
from typing import List, Dict, Optional, Set, Any, Tuple
|
|
3
3
|
|
|
4
|
+
import numpy as np
|
|
4
5
|
import torch
|
|
5
6
|
from torch import Tensor
|
|
6
7
|
from torch.utils.data import DataLoader
|
|
7
8
|
from scipy.sparse import csr_matrix
|
|
8
9
|
|
|
9
10
|
from warprec.data import Dataset
|
|
11
|
+
from warprec.data.stash import METRIC_ARGUMENTS, check_stash
|
|
10
12
|
from warprec.data.ranking import (
|
|
11
13
|
cold_item_candidates,
|
|
12
14
|
mask_seen_in_context,
|
|
@@ -131,8 +133,13 @@ class Evaluator:
|
|
|
131
133
|
"user_cluster": user_cluster,
|
|
132
134
|
"item_cluster": item_cluster,
|
|
133
135
|
"propensity": propensity,
|
|
134
|
-
**additional_data,
|
|
135
136
|
}
|
|
137
|
+
# The additional data (the dataset's stash) is passed next to these and
|
|
138
|
+
# to the cutoff, so a key of theirs would replace one of WarpRec's.
|
|
139
|
+
check_stash(
|
|
140
|
+
additional_data, {"k", *self.common_params, *METRIC_ARGUMENTS}, "metric"
|
|
141
|
+
)
|
|
142
|
+
self.common_params.update(additional_data)
|
|
136
143
|
self._init_metrics(metric_list, complex_metrics)
|
|
137
144
|
|
|
138
145
|
def _init_metrics(
|
|
@@ -542,6 +549,11 @@ class Evaluator:
|
|
|
542
549
|
def compute_results(self) -> Dict[int, Dict[str, float | Tensor]]:
|
|
543
550
|
"""The method to retrieve computed results in dictionary format.
|
|
544
551
|
|
|
552
|
+
Every value is either a tensor with one entry per user index, for a
|
|
553
|
+
metric averaged over users (NaN for a user it does not apply to), or a
|
|
554
|
+
Python float, for a global value. A 0-d tensor or another number a
|
|
555
|
+
metric returns is turned into a float.
|
|
556
|
+
|
|
545
557
|
Returns:
|
|
546
558
|
Dict[int, Dict[str, float | Tensor]]: The dictionary containing the results.
|
|
547
559
|
"""
|
|
@@ -550,9 +562,38 @@ class Evaluator:
|
|
|
550
562
|
results[k] = {}
|
|
551
563
|
for metric in metric_instances:
|
|
552
564
|
metric_result = metric.compute()
|
|
553
|
-
|
|
565
|
+
for name, value in metric_result.items():
|
|
566
|
+
results[k][name] = self._as_result(name, value)
|
|
554
567
|
return results
|
|
555
568
|
|
|
569
|
+
def _as_result(self, name: str, value: Any) -> float | Tensor:
|
|
570
|
+
"""Bring a metric's value to one of the two shapes results have.
|
|
571
|
+
|
|
572
|
+
Args:
|
|
573
|
+
name (str): The key the metric reports the value under.
|
|
574
|
+
value (Any): The value.
|
|
575
|
+
|
|
576
|
+
Returns:
|
|
577
|
+
float | Tensor: A tensor with one value per user, or a float.
|
|
578
|
+
|
|
579
|
+
Raises:
|
|
580
|
+
ValueError: If the value is neither a number nor a per-user tensor.
|
|
581
|
+
"""
|
|
582
|
+
num_users = self.common_params["num_users"]
|
|
583
|
+
if isinstance(value, Tensor):
|
|
584
|
+
if value.dim() == 0:
|
|
585
|
+
return float(value.item())
|
|
586
|
+
if value.dim() == 1 and value.numel() == num_users:
|
|
587
|
+
return value
|
|
588
|
+
elif isinstance(value, (int, float, np.number)) and not isinstance(value, bool):
|
|
589
|
+
return float(value)
|
|
590
|
+
shape = tuple(value.shape) if isinstance(value, Tensor) else None
|
|
591
|
+
raise ValueError(
|
|
592
|
+
f"The metric result '{name}' is a {type(value).__name__}"
|
|
593
|
+
f"{f' of shape {shape}' if shape is not None else ''}. A metric "
|
|
594
|
+
f"reports a tensor with one value per user ({num_users}) or a number."
|
|
595
|
+
)
|
|
596
|
+
|
|
556
597
|
def _retrieve_sequences_for_user(
|
|
557
598
|
self, dataset: Dataset, user_indices: List[int], max_seq_len: int
|
|
558
599
|
) -> Tuple[Tensor, Tensor]:
|
|
@@ -44,7 +44,7 @@ class AUC(BaseMetric):
|
|
|
44
44
|
)
|
|
45
45
|
|
|
46
46
|
def update(self, preds: Tensor, **kwargs: Any):
|
|
47
|
-
target =
|
|
47
|
+
target = self.block(kwargs, "binary_relevance", preds)
|
|
48
48
|
|
|
49
49
|
# Compute area and positives
|
|
50
50
|
area, positives = self.compute_area_stats(preds, target, self.num_items)
|
|
@@ -69,8 +69,7 @@ class F1(TopKMetric):
|
|
|
69
69
|
# Update needed blocks to be the union of the blocks
|
|
70
70
|
# of the two metrics
|
|
71
71
|
self._REQUIRED_COMPONENTS = (
|
|
72
|
-
self.metric_instance_1.
|
|
73
|
-
| self.metric_instance_2._REQUIRED_COMPONENTS
|
|
72
|
+
self.metric_instance_1.components | self.metric_instance_2.components
|
|
74
73
|
)
|
|
75
74
|
|
|
76
75
|
def update(self, preds: Tensor, user_indices: Tensor, **kwargs: Any):
|
|
@@ -40,8 +40,8 @@ class GAUC(UserAverageTopKMetric):
|
|
|
40
40
|
self.num_items = num_items
|
|
41
41
|
|
|
42
42
|
def unpack_inputs(self, preds: Tensor, **kwargs: Any) -> Tuple[Tensor, Tensor, Any]:
|
|
43
|
-
target =
|
|
44
|
-
users =
|
|
43
|
+
target = self.block(kwargs, "binary_relevance", preds)
|
|
44
|
+
users = self.block(kwargs, "valid_users", preds)
|
|
45
45
|
return target, users, None
|
|
46
46
|
|
|
47
47
|
def compute_scores(
|
|
@@ -28,12 +28,9 @@ class nDCG(UserAverageTopKMetric):
|
|
|
28
28
|
def unpack_inputs(
|
|
29
29
|
self, preds: Tensor, **kwargs: Any
|
|
30
30
|
) -> Tuple[Tensor, Tensor, Tensor]:
|
|
31
|
-
target =
|
|
32
|
-
users =
|
|
33
|
-
top_k_rel = kwargs.
|
|
34
|
-
f"top_{self.k}_discounted_relevance",
|
|
35
|
-
self.top_k_relevance(preds, target, self.k),
|
|
36
|
-
)
|
|
31
|
+
target = self.block(kwargs, "discounted_relevance", preds)
|
|
32
|
+
users = self.block(kwargs, "valid_users", preds)
|
|
33
|
+
top_k_rel = self.block(kwargs, f"top_{self.k}_discounted_relevance", preds)
|
|
37
34
|
return target, users, top_k_rel
|
|
38
35
|
|
|
39
36
|
def compute_scores(
|
|
@@ -8,11 +8,16 @@ from warprec.utils.enums import MetricBlock
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
class BaseMetric(Metric, ABC):
|
|
11
|
-
"""The base definition of a metric using Torchmetrics.
|
|
11
|
+
"""The base definition of a metric using Torchmetrics.
|
|
12
12
|
|
|
13
|
-
_REQUIRED_COMPONENTS
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
A metric declares in _REQUIRED_COMPONENTS the blocks it reads, which the
|
|
14
|
+
evaluator computes once per batch for every metric that asks. A metric that
|
|
15
|
+
reads none declares an empty set. One that leaves it undeclared (None) is
|
|
16
|
+
handed every block, which works whatever it reads but costs the blocks no
|
|
17
|
+
other metric needed.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
_REQUIRED_COMPONENTS: Optional[Set[MetricBlock]] = None
|
|
16
21
|
|
|
17
22
|
@abstractmethod
|
|
18
23
|
def compute(self) -> dict[str, float]:
|
|
@@ -245,14 +250,71 @@ class BaseMetric(Metric, ABC):
|
|
|
245
250
|
|
|
246
251
|
return area_per_user, positives_per_user
|
|
247
252
|
|
|
253
|
+
def block(self, blocks: dict, key: str, preds: Tensor) -> Tensor:
|
|
254
|
+
"""Read a block the evaluator computed, computing it when it did not.
|
|
255
|
+
|
|
256
|
+
The evaluator computes only the blocks some metric declared, and passes
|
|
257
|
+
None for the others. A block missing or None is derived here from the
|
|
258
|
+
ground truth ('ground') and the predictions, as the evaluator would.
|
|
259
|
+
|
|
260
|
+
Args:
|
|
261
|
+
blocks (dict): The keyword arguments the metric was updated with.
|
|
262
|
+
key (str): The block's key, e.g. 'binary_relevance' or
|
|
263
|
+
'top_10_indices'.
|
|
264
|
+
preds (Tensor): The prediction tensor.
|
|
265
|
+
|
|
266
|
+
Returns:
|
|
267
|
+
Tensor: The block.
|
|
268
|
+
|
|
269
|
+
Raises:
|
|
270
|
+
ValueError: If the block is neither given nor derivable, because
|
|
271
|
+
the ground truth is missing or the key names no block.
|
|
272
|
+
"""
|
|
273
|
+
value = blocks.get(key)
|
|
274
|
+
if value is not None:
|
|
275
|
+
return value
|
|
276
|
+
ground = blocks.get("ground")
|
|
277
|
+
if key.startswith("top_"):
|
|
278
|
+
k_text, _, block = key[len("top_") :].partition("_")
|
|
279
|
+
if k_text.isdigit():
|
|
280
|
+
k = int(k_text)
|
|
281
|
+
if block in ("values", "indices"):
|
|
282
|
+
values, indices = torch.topk(preds, k, dim=1)
|
|
283
|
+
return values if block == "values" else indices
|
|
284
|
+
if block in ("binary_relevance", "discounted_relevance"):
|
|
285
|
+
return self.top_k_relevance_from_indices(
|
|
286
|
+
self.block(blocks, block, preds),
|
|
287
|
+
self.block(blocks, f"top_{k}_indices", preds),
|
|
288
|
+
)
|
|
289
|
+
elif ground is not None:
|
|
290
|
+
derive = {
|
|
291
|
+
"binary_relevance": self.binary_relevance,
|
|
292
|
+
"discounted_relevance": self.discounted_relevance,
|
|
293
|
+
"valid_users": self.valid_users,
|
|
294
|
+
}.get(key)
|
|
295
|
+
if derive is not None:
|
|
296
|
+
return derive(ground)
|
|
297
|
+
raise ValueError(
|
|
298
|
+
f"{self.name} reads the block '{key}', which was not given and cannot "
|
|
299
|
+
"be derived: the ground truth 'ground' is missing or the key names no "
|
|
300
|
+
"block. Declare the blocks the metric reads in _REQUIRED_COMPONENTS."
|
|
301
|
+
)
|
|
302
|
+
|
|
248
303
|
@property
|
|
249
304
|
def name(self):
|
|
250
305
|
"""The name of the metric."""
|
|
251
306
|
return self.__class__.__name__
|
|
252
307
|
|
|
253
308
|
@property
|
|
254
|
-
def components(self):
|
|
255
|
-
"""The
|
|
309
|
+
def components(self) -> Set[MetricBlock]:
|
|
310
|
+
"""The blocks the evaluator computes for the metric.
|
|
311
|
+
|
|
312
|
+
Returns:
|
|
313
|
+
Set[MetricBlock]: The declared blocks, or every block when the
|
|
314
|
+
metric declares none.
|
|
315
|
+
"""
|
|
316
|
+
if self._REQUIRED_COMPONENTS is None:
|
|
317
|
+
return set(MetricBlock)
|
|
256
318
|
return self._REQUIRED_COMPONENTS
|
|
257
319
|
|
|
258
320
|
|
|
@@ -269,6 +331,9 @@ class RatingMetric(BaseMetric):
|
|
|
269
331
|
**kwargs (Any): Additional keyword arguments to pass to the parent class.
|
|
270
332
|
"""
|
|
271
333
|
|
|
334
|
+
# It reads the ground truth alone.
|
|
335
|
+
_REQUIRED_COMPONENTS: Optional[Set[MetricBlock]] = set()
|
|
336
|
+
|
|
272
337
|
error_sum: Tensor
|
|
273
338
|
total_count: Tensor
|
|
274
339
|
|
|
@@ -437,12 +502,9 @@ class UserAverageTopKMetric(TopKMetric):
|
|
|
437
502
|
- Tensor: The valid users tensor.
|
|
438
503
|
- Tensor: The top-k relevance tensor.
|
|
439
504
|
"""
|
|
440
|
-
target =
|
|
441
|
-
users =
|
|
442
|
-
top_k_rel = kwargs.
|
|
443
|
-
f"top_{self.k}_binary_relevance",
|
|
444
|
-
self.top_k_relevance(preds, target, self.k),
|
|
445
|
-
)
|
|
505
|
+
target = self.block(kwargs, "binary_relevance", preds)
|
|
506
|
+
users = self.block(kwargs, "valid_users", preds)
|
|
507
|
+
top_k_rel = self.block(kwargs, f"top_{self.k}_binary_relevance", preds)
|
|
446
508
|
return target, users, top_k_rel
|
|
447
509
|
|
|
448
510
|
@abstractmethod
|
|
@@ -473,9 +535,12 @@ class UserAverageTopKMetric(TopKMetric):
|
|
|
473
535
|
users > 0, batch_scores, torch.tensor(0.0, device=preds.device)
|
|
474
536
|
)
|
|
475
537
|
|
|
476
|
-
# Accumulate per user
|
|
477
|
-
|
|
478
|
-
self.
|
|
538
|
+
# Accumulate per user, in the accumulators' precision: a score read
|
|
539
|
+
# from the predictions is float64 when the model scores in float64.
|
|
540
|
+
self.scores.index_add_(0, user_indices, batch_scores.to(self.scores.dtype))
|
|
541
|
+
self.user_interactions.index_add_(
|
|
542
|
+
0, user_indices, users.to(self.user_interactions.dtype)
|
|
543
|
+
)
|
|
479
544
|
|
|
480
545
|
def compute(self):
|
|
481
546
|
"""Computes the final metric value."""
|
|
@@ -54,5 +54,5 @@ class ItemCoverage(TopKMetric):
|
|
|
54
54
|
self.item_counts += batch_counts.to(self.item_counts)
|
|
55
55
|
|
|
56
56
|
def compute(self):
|
|
57
|
-
item_coverage = (self.item_counts > 0).sum().item()
|
|
57
|
+
item_coverage = float((self.item_counts > 0).sum().item())
|
|
58
58
|
return {self.name: item_coverage}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
from typing import Any
|
|
1
|
+
from typing import Any, Set
|
|
2
2
|
|
|
3
3
|
import torch
|
|
4
4
|
from torch import Tensor
|
|
5
5
|
from warprec.evaluation.metrics.base_metric import TopKMetric
|
|
6
|
+
from warprec.utils.enums import MetricBlock
|
|
6
7
|
from warprec.utils.registry import metric_registry
|
|
7
8
|
|
|
8
9
|
|
|
@@ -23,6 +24,9 @@ class UserCoverageAtN(TopKMetric):
|
|
|
23
24
|
**kwargs (Any): The keyword argument dictionary.
|
|
24
25
|
"""
|
|
25
26
|
|
|
27
|
+
# It reads the predictions alone.
|
|
28
|
+
_REQUIRED_COMPONENTS: Set[MetricBlock] = set()
|
|
29
|
+
|
|
26
30
|
users: Tensor
|
|
27
31
|
|
|
28
32
|
def __init__(self, k: int, dist_sync_on_step: bool = False, **kwargs: Any):
|
|
@@ -40,4 +44,4 @@ class UserCoverageAtN(TopKMetric):
|
|
|
40
44
|
self.users += satisfied_users
|
|
41
45
|
|
|
42
46
|
def compute(self):
|
|
43
|
-
return {self.name:
|
|
47
|
+
return {self.name: float(self.users.item())}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
from typing import Any, Optional, Set, Tuple
|
|
2
2
|
|
|
3
|
-
import torch
|
|
4
3
|
from torch import Tensor
|
|
5
4
|
|
|
6
5
|
from warprec.evaluation.metrics.base_metric import UserAverageTopKMetric
|
|
@@ -117,12 +116,9 @@ class InversePropensityMetric(UserAverageTopKMetric):
|
|
|
117
116
|
Tuple[Tensor, Tensor, Tensor]: The target, the valid users and the
|
|
118
117
|
top-k relevance.
|
|
119
118
|
"""
|
|
120
|
-
target =
|
|
121
|
-
users =
|
|
122
|
-
top_k_rel = kwargs.
|
|
123
|
-
f"top_{self.k}_binary_relevance",
|
|
124
|
-
self.top_k_relevance(preds, target, self.k),
|
|
125
|
-
)
|
|
119
|
+
target = self.block(kwargs, "binary_relevance", preds)
|
|
120
|
+
users = self.block(kwargs, "valid_users", preds)
|
|
121
|
+
top_k_rel = self.block(kwargs, f"top_{self.k}_binary_relevance", preds)
|
|
126
122
|
return target, users, top_k_rel
|
|
127
123
|
|
|
128
124
|
def top_k_indices(self, preds: Tensor, **kwargs: Any) -> Tensor:
|
|
@@ -135,7 +131,4 @@ class InversePropensityMetric(UserAverageTopKMetric):
|
|
|
135
131
|
Returns:
|
|
136
132
|
Tensor: The top-k indices.
|
|
137
133
|
"""
|
|
138
|
-
|
|
139
|
-
if indices is None:
|
|
140
|
-
_, indices = torch.topk(preds, self.k, dim=1)
|
|
141
|
-
return indices
|
|
134
|
+
return self.block(kwargs, f"top_{self.k}_indices", preds)
|
|
@@ -65,7 +65,7 @@ class ShannonEntropy(TopKMetric):
|
|
|
65
65
|
def compute(self):
|
|
66
66
|
# Avoid division by zero
|
|
67
67
|
if self.total_recs == 0:
|
|
68
|
-
return {self.name:
|
|
68
|
+
return {self.name: 0.0}
|
|
69
69
|
|
|
70
70
|
# Calculate probability distribution
|
|
71
71
|
probs = self.item_counts / self.total_recs
|
|
@@ -57,7 +57,7 @@ class BiasDisparityBD(TopKMetric):
|
|
|
57
57
|
|
|
58
58
|
# Union of required components
|
|
59
59
|
self._REQUIRED_COMPONENTS = (
|
|
60
|
-
self.bs_metric.
|
|
60
|
+
self.bs_metric.components | self.br_metric.components
|
|
61
61
|
)
|
|
62
62
|
|
|
63
63
|
# Metadata for formatting
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
from typing import Any, Optional, Tuple
|
|
1
|
+
from typing import Any, Optional, Set, Tuple
|
|
2
2
|
|
|
3
3
|
import numpy as np
|
|
4
4
|
import torch
|
|
5
5
|
from scipy.sparse import csr_matrix
|
|
6
6
|
from torch import Tensor
|
|
7
7
|
|
|
8
|
+
from warprec.utils.enums import MetricBlock
|
|
8
9
|
from warprec.utils.registry import metric_registry
|
|
9
10
|
from warprec.evaluation.metrics.base_metric import BaseMetric
|
|
10
11
|
|
|
@@ -41,6 +42,9 @@ class BiasDisparityBS(BaseMetric):
|
|
|
41
42
|
ValueError: If the training interactions were not provided.
|
|
42
43
|
"""
|
|
43
44
|
|
|
45
|
+
# It reads the training split alone.
|
|
46
|
+
_REQUIRED_COMPONENTS: Set[MetricBlock] = set()
|
|
47
|
+
|
|
44
48
|
user_clusters: Tensor
|
|
45
49
|
item_clusters: Tensor
|
|
46
50
|
PC: Tensor
|
|
@@ -86,7 +86,7 @@ class ItemMADRanking(TopKMetric):
|
|
|
86
86
|
recommended_mask = self.item_counts > 0
|
|
87
87
|
|
|
88
88
|
if not recommended_mask.any():
|
|
89
|
-
return {self.name:
|
|
89
|
+
return {self.name: 0.0}
|
|
90
90
|
|
|
91
91
|
item_avg_gains = torch.zeros_like(self.item_gains)
|
|
92
92
|
item_avg_gains[recommended_mask] = (
|
|
@@ -110,7 +110,7 @@ class ItemMADRanking(TopKMetric):
|
|
|
110
110
|
valid_clusters = cluster_counts > 0
|
|
111
111
|
|
|
112
112
|
if not valid_clusters.any():
|
|
113
|
-
return {self.name:
|
|
113
|
+
return {self.name: 0.0}
|
|
114
114
|
|
|
115
115
|
cluster_means = (
|
|
116
116
|
cluster_sum_gains[valid_clusters] / cluster_counts[valid_clusters]
|
|
@@ -78,7 +78,10 @@ class ItemMADRating(TopKMetric):
|
|
|
78
78
|
# Filter only Relevant items (True Positives)
|
|
79
79
|
# We select elements from global_indices and top_k_values where relevance_mask is True
|
|
80
80
|
relevant_indices = torch.masked_select(top_k_indices, rel_mask)
|
|
81
|
-
|
|
81
|
+
# In the accumulators' precision: float64 when the model scores in float64.
|
|
82
|
+
relevant_scores = torch.masked_select(top_k_values, rel_mask).to(
|
|
83
|
+
self.item_gains.dtype
|
|
84
|
+
)
|
|
82
85
|
|
|
83
86
|
if relevant_indices.numel() > 0:
|
|
84
87
|
# Accumulate counts (1 for every relevant appearance)
|
|
@@ -94,7 +97,7 @@ class ItemMADRating(TopKMetric):
|
|
|
94
97
|
recommended_mask = self.item_counts > 0
|
|
95
98
|
|
|
96
99
|
if not recommended_mask.any():
|
|
97
|
-
return {self.name:
|
|
100
|
+
return {self.name: 0.0}
|
|
98
101
|
|
|
99
102
|
item_avg_ratings = torch.zeros_like(self.item_gains)
|
|
100
103
|
item_avg_ratings[recommended_mask] = (
|
|
@@ -116,7 +119,7 @@ class ItemMADRating(TopKMetric):
|
|
|
116
119
|
valid_clusters = cluster_counts > 0
|
|
117
120
|
|
|
118
121
|
if not valid_clusters.any():
|
|
119
|
-
return {self.name:
|
|
122
|
+
return {self.name: 0.0}
|
|
120
123
|
|
|
121
124
|
cluster_means = (
|
|
122
125
|
cluster_sum_ratings[valid_clusters] / cluster_counts[valid_clusters]
|
|
@@ -52,12 +52,9 @@ class UserMADRanking(UserAverageTopKMetric):
|
|
|
52
52
|
def unpack_inputs(
|
|
53
53
|
self, preds: Tensor, **kwargs: Any
|
|
54
54
|
) -> Tuple[Tensor, Tensor, Tensor]:
|
|
55
|
-
target =
|
|
56
|
-
users =
|
|
57
|
-
top_k_rel = kwargs.
|
|
58
|
-
f"top_{self.k}_discounted_relevance",
|
|
59
|
-
self.top_k_relevance(preds, target, self.k),
|
|
60
|
-
)
|
|
55
|
+
target = self.block(kwargs, "discounted_relevance", preds)
|
|
56
|
+
users = self.block(kwargs, "valid_users", preds)
|
|
57
|
+
top_k_rel = self.block(kwargs, f"top_{self.k}_discounted_relevance", preds)
|
|
61
58
|
return target, users, top_k_rel
|
|
62
59
|
|
|
63
60
|
def compute_scores(
|
|
@@ -78,7 +75,7 @@ class UserMADRanking(UserAverageTopKMetric):
|
|
|
78
75
|
mask = self.user_interactions > 0
|
|
79
76
|
|
|
80
77
|
if not mask.any():
|
|
81
|
-
return {self.name:
|
|
78
|
+
return {self.name: 0.0}
|
|
82
79
|
|
|
83
80
|
user_vals = torch.zeros_like(self.scores)
|
|
84
81
|
user_vals[mask] = self.scores[mask] / self.user_interactions[mask]
|
|
@@ -98,7 +95,7 @@ class UserMADRanking(UserAverageTopKMetric):
|
|
|
98
95
|
valid_clusters = count_cluster > 0
|
|
99
96
|
|
|
100
97
|
if not valid_clusters.any():
|
|
101
|
-
return {self.name:
|
|
98
|
+
return {self.name: 0.0}
|
|
102
99
|
|
|
103
100
|
mean_cluster = sum_cluster[valid_clusters] / count_cluster[valid_clusters]
|
|
104
101
|
|
|
@@ -63,7 +63,7 @@ class UserMADRating(UserAverageTopKMetric):
|
|
|
63
63
|
mask = self.user_interactions > 0
|
|
64
64
|
|
|
65
65
|
if not mask.any():
|
|
66
|
-
return {self.name:
|
|
66
|
+
return {self.name: 0.0}
|
|
67
67
|
|
|
68
68
|
user_vals = torch.zeros_like(self.scores)
|
|
69
69
|
user_vals[mask] = self.scores[mask] / self.user_interactions[mask]
|
|
@@ -81,7 +81,7 @@ class UserMADRating(UserAverageTopKMetric):
|
|
|
81
81
|
valid_clusters = count_cluster > 0
|
|
82
82
|
|
|
83
83
|
if not valid_clusters.any():
|
|
84
|
-
return {self.name:
|
|
84
|
+
return {self.name: 0.0}
|
|
85
85
|
|
|
86
86
|
mean_cluster = sum_cluster[valid_clusters] / count_cluster[valid_clusters]
|
|
87
87
|
|
{warprec-2.1.7 → warprec-2.1.8}/warprec/evaluation/metrics/multiobjective/euclideandistance.py
RENAMED
|
@@ -72,7 +72,7 @@ class EucDistance(TopKMetric):
|
|
|
72
72
|
)
|
|
73
73
|
self.sub_metrics.append(m_inst)
|
|
74
74
|
# Collect and union all required data components from sub-metrics
|
|
75
|
-
required_blocks |= m_inst.
|
|
75
|
+
required_blocks |= m_inst.components
|
|
76
76
|
|
|
77
77
|
self._REQUIRED_COMPONENTS = required_blocks
|
|
78
78
|
|
|
@@ -78,7 +78,7 @@ class Hypervolume(TopKMetric):
|
|
|
78
78
|
)
|
|
79
79
|
self.sub_metrics.append(m_inst)
|
|
80
80
|
# Collect and union all required data components from sub-metrics
|
|
81
|
-
required_blocks |= m_inst.
|
|
81
|
+
required_blocks |= m_inst.components
|
|
82
82
|
|
|
83
83
|
self._REQUIRED_COMPONENTS = required_blocks
|
|
84
84
|
|
|
@@ -2,6 +2,7 @@ import time
|
|
|
2
2
|
|
|
3
3
|
import lightning as L
|
|
4
4
|
|
|
5
|
+
from warprec.data.stash import MODEL_ARGUMENTS, check_stash
|
|
5
6
|
from warprec.common import initialize_datasets, log_evaluation
|
|
6
7
|
from warprec.data.reader import ReaderFactory
|
|
7
8
|
from warprec.recommenders.base_recommender import IterativeRecommender
|
|
@@ -90,7 +91,7 @@ def design_pipeline(path: str):
|
|
|
90
91
|
sessions=main_dataset.train_session,
|
|
91
92
|
seed=seed,
|
|
92
93
|
info=main_dataset.info(),
|
|
93
|
-
**main_dataset.get_stash(),
|
|
94
|
+
**check_stash(main_dataset.get_stash(), MODEL_ARGUMENTS, "model"),
|
|
94
95
|
block_size=block_size,
|
|
95
96
|
chunk_size=chunk_size,
|
|
96
97
|
)
|