warprec 2.2.5__tar.gz → 2.2.7__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.2.5 → warprec-2.2.7}/PKG-INFO +6 -6
- {warprec-2.2.5 → warprec-2.2.7}/README.md +5 -5
- {warprec-2.2.5 → warprec-2.2.7}/pyproject.toml +1 -1
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/ranking.py +102 -45
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/writer/base_writer.py +10 -15
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/evaluator.py +28 -12
- {warprec-2.2.5 → warprec-2.2.7}/warprec/pipelines/common.py +111 -81
- {warprec-2.2.5 → warprec-2.2.7}/warprec/pipelines/design.py +2 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/pipelines/estimate.py +5 -3
- {warprec-2.2.5 → warprec-2.2.7}/warprec/pipelines/eval.py +2 -0
- warprec-2.2.7/warprec/pipelines/remotes/__init__.py +21 -0
- warprec-2.2.7/warprec/pipelines/remotes/data.py +247 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/pipelines/remotes/ml.py +205 -9
- {warprec-2.2.5 → warprec-2.2.7}/warprec/pipelines/swarm.py +55 -119
- {warprec-2.2.5 → warprec-2.2.7}/warprec/pipelines/train.py +81 -176
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/base_recommender.py +39 -19
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/callbacks.py +20 -5
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/neural/twotower.py +3 -3
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/knowledge_aware_recommender/cke.py +2 -2
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/knowledge_aware_recommender/kahfm.py +3 -3
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/knowledge_aware_recommender/kgat.py +2 -2
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/knowledge_aware_recommender/kgcn.py +2 -2
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/knowledge_aware_recommender/kgflex.py +9 -6
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/knowledge_aware_recommender/kgin.py +7 -3
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/knowledge_aware_recommender/knowledge_utils.py +0 -1
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/knowledge_aware_recommender/ripplenet.py +11 -5
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/multimodal_recommender/bm3.py +2 -2
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/multimodal_recommender/freedom.py +2 -2
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/multimodal_recommender/lattice.py +2 -2
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/multimodal_recommender/mgcn.py +2 -2
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/multimodal_recommender/mmgcn.py +2 -2
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/multimodal_recommender/vbpr.py +2 -2
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/reranking/__init__.py +2 -1
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/reranking/base.py +26 -3
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/reranking/calibration.py +5 -0
- warprec-2.2.7/warprec/recommenders/reranking/factory.py +78 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/sequential_recommender/gsasrec.py +54 -49
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/sequential_recommender/stan.py +25 -21
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/trainer/objectives.py +4 -0
- warprec-2.2.7/warprec/recommenders/trainer/search_algorithm_wrapper.py +408 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/trainer/trainer.py +179 -51
- {warprec-2.2.5 → warprec-2.2.7}/warprec/serving/deployments.py +1 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/serving/payload.py +19 -3
- {warprec-2.2.5 → warprec-2.2.7}/warprec/serving/servable.py +189 -36
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/config/general_configuration.py +5 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/config/serving_configuration.py +34 -0
- warprec-2.2.7/warprec/utils/determinism.py +34 -0
- warprec-2.2.5/warprec/pipelines/remotes/__init__.py +0 -9
- warprec-2.2.5/warprec/pipelines/remotes/data.py +0 -101
- warprec-2.2.5/warprec/recommenders/reranking/factory.py +0 -44
- warprec-2.2.5/warprec/recommenders/trainer/search_algorithm_wrapper.py +0 -187
- {warprec-2.2.5 → warprec-2.2.7}/LICENSE +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/common/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/common/initialize.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/common/run_state.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/common/std_logs.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/dataset.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/entities/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/entities/common.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/entities/context.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/entities/interactions.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/entities/knowledge.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/entities/multimodal.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/entities/sessions.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/entities/train_structures/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/entities/train_structures/custom_collate_fn.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/entities/train_structures/interaction_structures.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/entities/train_structures/session_structures.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/entities/transactions.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/eval_loaders.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/filtering.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/reader/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/reader/azureblob_reader.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/reader/base_reader.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/reader/local_reader.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/schema.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/splitting/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/splitting/splitter.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/splitting/strategies.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/stash.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/timing.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/writer/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/writer/azureblob_writer.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/data/writer/local_writer.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/errors.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/factory.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/accuracy/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/accuracy/auc.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/accuracy/f1.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/accuracy/gauc.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/accuracy/hit_rate.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/accuracy/lauc.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/accuracy/logloss.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/accuracy/map.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/accuracy/mar.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/accuracy/mrr.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/accuracy/ndcg.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/accuracy/precision.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/accuracy/recall.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/base_metric.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/bias/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/bias/aclt.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/bias/aplt.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/bias/arp.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/bias/long_tail.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/bias/pop_reo.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/bias/pop_rsp.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/coverage/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/coverage/item_coverage.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/coverage/numretrieved.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/coverage/user_coverage.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/coverage/user_coverage_at_n.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/debiased/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/debiased/base.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/debiased/dcg.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/debiased/recall.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/diversity/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/diversity/gini_index.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/diversity/shannon_entropy.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/diversity/srecall.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/fairness/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/fairness/biasdisparitybd.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/fairness/biasdisparitybr.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/fairness/biasdisparitybs.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/fairness/itemmadranking.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/fairness/itemmadrating.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/fairness/reo.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/fairness/rsp.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/fairness/usermadranking.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/fairness/usermadrating.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/multiobjective/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/multiobjective/euclideandistance.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/multiobjective/hypervolume.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/novelty/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/novelty/efd.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/novelty/epc.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/novelty/novelty_profile.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/rating/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/rating/mae.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/rating/mse.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/metrics/rating/rmse.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/propensity.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/evaluation/statistical_significance.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/pipelines/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/cdae.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/diffrec.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/ease.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/elsa.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/macridvae.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/multidae.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/multivae.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/sansa.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/graph_based/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/graph_based/dgcf.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/graph_based/egcf.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/graph_based/esigcf.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/graph_based/gcmc.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/graph_based/graph_utils.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightccf.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgcl.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgcn.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgcnpp.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgode.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/graph_based/macrgcn.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/graph_based/mixrec.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/graph_based/ngcf.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/graph_based/paac.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/graph_based/popdcl.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/graph_based/recdcl.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/graph_based/rp3beta.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/graph_based/sgcl.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/graph_based/sgl.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/graph_based/simgcl.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/graph_based/simrec.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/graph_based/ultragcn.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/graph_based/xsimgcl.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/knn/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/knn/itemknn.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/knn/itemknntd.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/knn/userknn.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/knn/userknntd.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/admmslim.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/bpr.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/fism.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/ials.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/ials2008.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/macrmf.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/slim.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/neural/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/neural/convncf.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/collaborative_filtering_recommender/neural/neumf.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/content_based_recommender/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/content_based_recommender/vsm.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/context_aware_recommender/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/context_aware_recommender/afm.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/context_aware_recommender/dcn.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/context_aware_recommender/dcnv2.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/context_aware_recommender/deepfm.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/context_aware_recommender/fm.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/context_aware_recommender/nfm.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/context_aware_recommender/wideanddeep.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/context_aware_recommender/xdeepfm.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/hybrid_recommender/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/hybrid_recommender/addease.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/hybrid_recommender/attributeitemknn.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/hybrid_recommender/attributeuserknn.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/hybrid_recommender/cease.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/knowledge_aware_recommender/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/layers.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/losses.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/lr_scheduler_wrapper.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/multimodal_recommender/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/multimodal_recommender/multimodal_utils.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/optimizer_wrapper.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/proxy.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/reranking/mmr.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/sequential_recommender/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/sequential_recommender/bert4rec.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/sequential_recommender/bsarec.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/sequential_recommender/caser.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/sequential_recommender/cl4srec.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/sequential_recommender/core.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/sequential_recommender/duorec.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/sequential_recommender/esasrec.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/sequential_recommender/fossil.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/sequential_recommender/gru4rec.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/sequential_recommender/lightsans.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/sequential_recommender/linrec.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/sequential_recommender/narm.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/sequential_recommender/sasrec.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/similarities.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/trainer/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/trainer/dashboard_callbacks.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/trainer/emissions.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/trainer/logger_callbacks.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/trainer/runtime.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/trainer/scheduler_wrapper.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/trainer/timing.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/unpersonalized_recommender/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/unpersonalized_recommender/pop.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/recommenders/unpersonalized_recommender/random.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/run.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/serve.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/serving/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/serving/api.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/serving/app.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/serving/catalogue.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/serving/context.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/serving/errors.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/serving/mcp.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/serving/schemas.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/callback.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/config/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/config/common.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/config/config.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/config/dashboard_configuration.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/config/estimate_configuration.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/config/evaluation_configuration.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/config/model_configuration.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/config/reader_configuration.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/config/recommender_model_config/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/autoencoder_config.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/graph_based_config.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/knn_config.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/latent_factor_config.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/neural_config.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/config/recommender_model_config/content_based_config.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/config/recommender_model_config/context_aware_config.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/config/recommender_model_config/hybrid_config.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/config/recommender_model_config/knowledge_aware_config.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/config/recommender_model_config/multimodal_config.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/config/recommender_model_config/sequential_model_config.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/config/recommender_model_config/unpersonalized_config.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/config/rerank_configuration.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/config/run_configuration.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/config/search_space_wrapper.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/config/splitter_configuration.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/config/training_configuration.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/config/writer_configuration.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/enums.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/helpers.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/logger/__init__.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/logger/logger.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/pause.py +0 -0
- {warprec-2.2.5 → warprec-2.2.7}/warprec/utils/registry.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: warprec
|
|
3
|
-
Version: 2.2.
|
|
3
|
+
Version: 2.2.7
|
|
4
4
|
Summary: Unifying Academic Rigor and Industrial Scale for Responsible, Reproducible, and Efficient Recommendation
|
|
5
5
|
Author: MarcoWV
|
|
6
6
|
Author-email: marco.avolio@wideverse.com
|
|
@@ -120,16 +120,16 @@ An **Application Layer** serves trained models on Ray Serve, as a batched REST A
|
|
|
120
120
|
|
|
121
121
|
## ✨ Key Features
|
|
122
122
|
|
|
123
|
-
- **
|
|
124
|
-
- **Backend-Agnostic Data Engine**: Built on [Narwhals](https://narwhals-dev.github.io/narwhals/), WarpRec operates over Pandas
|
|
123
|
+
- **87 Built-in Algorithms**: WarpRec ships with 87 state-of-the-art recommendation models spanning 8 paradigms — Unpersonalized, Content-Based, Collaborative Filtering (e.g., `LightGCN`, `EASE`$^R$, `MultiVAE`), Context-Aware (e.g., `DeepFM`, `xDeepFM`), Sequential (e.g., `SASRec`, `BERT4Rec`, `GRU4Rec`), Knowledge-Aware (e.g., `KGAT`, `KGIN`, `KaHFM`, `KGFlex`), Multimodal (e.g., `VBPR`, `FREEDOM`, `BM3`), and Hybrid. All models are fully configurable and extend a standardized base class, making it easy to prototype custom architectures within the same pipeline.
|
|
124
|
+
- **Backend-Agnostic Data Engine**: Built on [Narwhals](https://narwhals-dev.github.io/narwhals/), WarpRec operates over Pandas and Polars without code changes — enabling a true "write-once, run-anywhere" workflow from laptop to distributed cluster. Data ingestion supports both local filesystems and cloud object storage (Azure Blob Storage).
|
|
125
125
|
- **Comprehensive Data Processing**: The data module provides 13 filtering strategies (filter-by-rating, k-core, cold-start heuristics) and 8 splitting protocols (random/temporal Hold-Out, Leave-k-Out, Fixed Timestamp, k-fold Cross-Validation, item and user cold-start), for a total of 21 configurable strategies to ensure rigorous and reproducible experimental setups.
|
|
126
|
-
- **45 GPU-Accelerated Metrics**: The evaluation suite covers 45 metrics across
|
|
127
|
-
- **Statistical Rigor**: WarpRec automates hypothesis testing with paired (Student's t-test, Wilcoxon signed-rank) and independent-group (Mann-Whitney U) tests, and applies multiple comparison corrections via **Bonferroni** and **FDR (Benjamini-Hochberg)** to prevent p-hacking and ensure statistically robust conclusions.
|
|
126
|
+
- **45 GPU-Accelerated Metrics**: The evaluation suite covers 45 metrics across 9 families — Accuracy, Rating, Coverage, Novelty, Diversity, Bias, Fairness, Debiased and Multi-objective — including metrics for the simultaneous optimization of competing goals, and inverse-propensity estimators that correct for exposure bias. All metrics are computed with full GPU acceleration for large-scale experiments.
|
|
127
|
+
- **Statistical Rigor**: WarpRec automates hypothesis testing with paired (Student's t-test, Wilcoxon signed-rank) and independent-group (Kruskal-Wallis, Mann-Whitney U) tests, and applies multiple comparison corrections via **Bonferroni**, **Holm-Bonferroni** and **FDR (Benjamini-Hochberg)** to prevent p-hacking and ensure statistically robust conclusions.
|
|
128
128
|
- **Distributed Training & HPO**: Seamless vertical and horizontal scaling from single-GPU to multi-node Ray clusters. Hyperparameter optimization supports Grid, Random, Bayesian, HyperOpt, Optuna, and BoHB strategies, with ASHA pruning and model-level early stopping to maximize computational efficiency.
|
|
129
129
|
- **Pausable & Resumable Runs**: Long experiments can be stopped with a signal (`Ctrl+C` or `SIGTERM`) and resumed later from the same command. Unfinished Ray Tune trials continue from their last checkpoint and models that already completed are skipped, so a preemption on a spot instance or a cluster reclaim costs minutes rather than the whole experiment.
|
|
130
130
|
- **Green AI & Carbon Tracking**: WarpRec is the first recommendation framework with native [CodeCarbon](https://codecarbon.io/) integration, automatically quantifying energy consumption and CO₂ emissions for every experiment and persisting carbon footprint reports alongside standard results.
|
|
131
131
|
- **Agentic AI via MCP**: Served models can also be exposed as [Model Context Protocol](https://modelcontextprotocol.io/) tools on the same server (`server.mcp: true`), so LLMs and autonomous agents call a trained recommender as a tool — transforming the framework from a static predictor into an interactive, agent-ready component.
|
|
132
|
-
- **Model Serving on Ray Serve**: A model saved by the training pipeline is served with `python -m warprec.serve -c serve.yml` — a batched REST API with replicas, autoscaling and GPU placement set in configuration, and exportable to a Ray cluster or KubeRay.
|
|
132
|
+
- **Model Serving on Ray Serve**: A model saved by the training pipeline is served with `python -m warprec.serve -c serve.yml` — a batched REST API with replicas, autoscaling and GPU placement set in configuration, and exportable to a Ray cluster or KubeRay. Every model family, knowledge-aware and multimodal included, is served from the checkpoint alone.
|
|
133
133
|
- **Experiment Tracking**: Native integrations with `Weights & Biases` and `MLflow` for real-time monitoring of metrics, training dynamics and multi-run management, and `CodeCarbon` for the energy and emissions of every trial.
|
|
134
134
|
- **Custom Pipelines & Callbacks**: Alongside the standard Training, Design, Evaluation, Swarm, and Estimate workflows, WarpRec exposes an event-driven Callback system for injecting custom logic at any stage — enabling complex experiments without modifying framework internals.
|
|
135
135
|
|
|
@@ -60,16 +60,16 @@ An **Application Layer** serves trained models on Ray Serve, as a batched REST A
|
|
|
60
60
|
|
|
61
61
|
## ✨ Key Features
|
|
62
62
|
|
|
63
|
-
- **
|
|
64
|
-
- **Backend-Agnostic Data Engine**: Built on [Narwhals](https://narwhals-dev.github.io/narwhals/), WarpRec operates over Pandas
|
|
63
|
+
- **87 Built-in Algorithms**: WarpRec ships with 87 state-of-the-art recommendation models spanning 8 paradigms — Unpersonalized, Content-Based, Collaborative Filtering (e.g., `LightGCN`, `EASE`$^R$, `MultiVAE`), Context-Aware (e.g., `DeepFM`, `xDeepFM`), Sequential (e.g., `SASRec`, `BERT4Rec`, `GRU4Rec`), Knowledge-Aware (e.g., `KGAT`, `KGIN`, `KaHFM`, `KGFlex`), Multimodal (e.g., `VBPR`, `FREEDOM`, `BM3`), and Hybrid. All models are fully configurable and extend a standardized base class, making it easy to prototype custom architectures within the same pipeline.
|
|
64
|
+
- **Backend-Agnostic Data Engine**: Built on [Narwhals](https://narwhals-dev.github.io/narwhals/), WarpRec operates over Pandas and Polars without code changes — enabling a true "write-once, run-anywhere" workflow from laptop to distributed cluster. Data ingestion supports both local filesystems and cloud object storage (Azure Blob Storage).
|
|
65
65
|
- **Comprehensive Data Processing**: The data module provides 13 filtering strategies (filter-by-rating, k-core, cold-start heuristics) and 8 splitting protocols (random/temporal Hold-Out, Leave-k-Out, Fixed Timestamp, k-fold Cross-Validation, item and user cold-start), for a total of 21 configurable strategies to ensure rigorous and reproducible experimental setups.
|
|
66
|
-
- **45 GPU-Accelerated Metrics**: The evaluation suite covers 45 metrics across
|
|
67
|
-
- **Statistical Rigor**: WarpRec automates hypothesis testing with paired (Student's t-test, Wilcoxon signed-rank) and independent-group (Mann-Whitney U) tests, and applies multiple comparison corrections via **Bonferroni** and **FDR (Benjamini-Hochberg)** to prevent p-hacking and ensure statistically robust conclusions.
|
|
66
|
+
- **45 GPU-Accelerated Metrics**: The evaluation suite covers 45 metrics across 9 families — Accuracy, Rating, Coverage, Novelty, Diversity, Bias, Fairness, Debiased and Multi-objective — including metrics for the simultaneous optimization of competing goals, and inverse-propensity estimators that correct for exposure bias. All metrics are computed with full GPU acceleration for large-scale experiments.
|
|
67
|
+
- **Statistical Rigor**: WarpRec automates hypothesis testing with paired (Student's t-test, Wilcoxon signed-rank) and independent-group (Kruskal-Wallis, Mann-Whitney U) tests, and applies multiple comparison corrections via **Bonferroni**, **Holm-Bonferroni** and **FDR (Benjamini-Hochberg)** to prevent p-hacking and ensure statistically robust conclusions.
|
|
68
68
|
- **Distributed Training & HPO**: Seamless vertical and horizontal scaling from single-GPU to multi-node Ray clusters. Hyperparameter optimization supports Grid, Random, Bayesian, HyperOpt, Optuna, and BoHB strategies, with ASHA pruning and model-level early stopping to maximize computational efficiency.
|
|
69
69
|
- **Pausable & Resumable Runs**: Long experiments can be stopped with a signal (`Ctrl+C` or `SIGTERM`) and resumed later from the same command. Unfinished Ray Tune trials continue from their last checkpoint and models that already completed are skipped, so a preemption on a spot instance or a cluster reclaim costs minutes rather than the whole experiment.
|
|
70
70
|
- **Green AI & Carbon Tracking**: WarpRec is the first recommendation framework with native [CodeCarbon](https://codecarbon.io/) integration, automatically quantifying energy consumption and CO₂ emissions for every experiment and persisting carbon footprint reports alongside standard results.
|
|
71
71
|
- **Agentic AI via MCP**: Served models can also be exposed as [Model Context Protocol](https://modelcontextprotocol.io/) tools on the same server (`server.mcp: true`), so LLMs and autonomous agents call a trained recommender as a tool — transforming the framework from a static predictor into an interactive, agent-ready component.
|
|
72
|
-
- **Model Serving on Ray Serve**: A model saved by the training pipeline is served with `python -m warprec.serve -c serve.yml` — a batched REST API with replicas, autoscaling and GPU placement set in configuration, and exportable to a Ray cluster or KubeRay.
|
|
72
|
+
- **Model Serving on Ray Serve**: A model saved by the training pipeline is served with `python -m warprec.serve -c serve.yml` — a batched REST API with replicas, autoscaling and GPU placement set in configuration, and exportable to a Ray cluster or KubeRay. Every model family, knowledge-aware and multimodal included, is served from the checkpoint alone.
|
|
73
73
|
- **Experiment Tracking**: Native integrations with `Weights & Biases` and `MLflow` for real-time monitoring of metrics, training dynamics and multi-run management, and `CodeCarbon` for the energy and emissions of every trial.
|
|
74
74
|
- **Custom Pipelines & Callbacks**: Alongside the standard Training, Design, Evaluation, Swarm, and Estimate workflows, WarpRec exposes an event-driven Callback system for injecting custom logic at any stage — enabling complex experiments without modifying framework internals.
|
|
75
75
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Any, Dict, Optional, Tuple
|
|
1
|
+
from typing import TYPE_CHECKING, Any, Dict, Optional, Tuple, Union
|
|
2
2
|
|
|
3
3
|
import numpy as np
|
|
4
4
|
import torch
|
|
@@ -9,6 +9,9 @@ from warprec.errors import EvaluationError
|
|
|
9
9
|
from warprec.data.entities.context import context_key
|
|
10
10
|
from warprec.utils.logger import logger
|
|
11
11
|
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from warprec.recommenders.reranking.base import Reranker
|
|
14
|
+
|
|
12
15
|
|
|
13
16
|
def mask_seen_pairs(predictions: Tensor, seen: csr_matrix) -> None:
|
|
14
17
|
"""Exclude from the ranking every item a user has already interacted with.
|
|
@@ -20,6 +23,74 @@ def mask_seen_pairs(predictions: Tensor, seen: csr_matrix) -> None:
|
|
|
20
23
|
predictions[seen.nonzero()] = -torch.inf
|
|
21
24
|
|
|
22
25
|
|
|
26
|
+
class SeenItems:
|
|
27
|
+
"""The items every user has seen, held where the scores are computed.
|
|
28
|
+
|
|
29
|
+
Masking them with ``mask_seen_pairs`` slices the training matrix with scipy
|
|
30
|
+
and lists its non-zero entries on the host for every batch. This keeps the
|
|
31
|
+
matrix's compressed rows as tensors on the evaluation device instead, so a
|
|
32
|
+
batch is masked by a few tensor operations there, without leaving it.
|
|
33
|
+
|
|
34
|
+
On a CUDA device whose free memory the rows would crowd, they stay on the
|
|
35
|
+
host, and only the entries of each batch are sent to the device.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
seen (csr_matrix): The {user x item} training matrix. Entries stored as
|
|
39
|
+
explicit zeros are not seen, as with ``mask_seen_pairs``.
|
|
40
|
+
device (Union[str, torch.device]): The device the scores are on.
|
|
41
|
+
|
|
42
|
+
Attributes:
|
|
43
|
+
MEMORY_SHARE (float): The share of a CUDA device's free memory the
|
|
44
|
+
rows may take.
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
MEMORY_SHARE: float = 0.25
|
|
48
|
+
|
|
49
|
+
def __init__(self, seen: csr_matrix, device: Union[str, torch.device] = "cpu"):
|
|
50
|
+
seen = csr_matrix(seen, copy=True)
|
|
51
|
+
seen.eliminate_zeros()
|
|
52
|
+
|
|
53
|
+
home = torch.device(device)
|
|
54
|
+
size = seen.indptr.size * 8 + seen.indices.size * 4
|
|
55
|
+
if (
|
|
56
|
+
home.type == "cuda"
|
|
57
|
+
and size > torch.cuda.mem_get_info(home)[0] * self.MEMORY_SHARE
|
|
58
|
+
):
|
|
59
|
+
home = torch.device("cpu")
|
|
60
|
+
|
|
61
|
+
self.indptr = torch.as_tensor(seen.indptr.astype(np.int64)).to(home)
|
|
62
|
+
self.indices = torch.as_tensor(seen.indices.astype(np.int32)).to(home)
|
|
63
|
+
|
|
64
|
+
def mask(self, predictions: Tensor, user_indices: Tensor) -> None:
|
|
65
|
+
"""Exclude from a batch's ranking every item its users have seen.
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
predictions (Tensor): The score matrix, one row per user of the
|
|
69
|
+
batch, modified in place.
|
|
70
|
+
user_indices (Tensor): The user of each row.
|
|
71
|
+
"""
|
|
72
|
+
home = self.indptr.device
|
|
73
|
+
users = user_indices.to(home, torch.long)
|
|
74
|
+
starts = self.indptr[users]
|
|
75
|
+
counts = self.indptr[users + 1] - starts
|
|
76
|
+
total = int(counts.sum())
|
|
77
|
+
if total == 0:
|
|
78
|
+
return
|
|
79
|
+
|
|
80
|
+
# Every seen entry of the batch: its row in the batch, and its position
|
|
81
|
+
# in the matrix's column indices
|
|
82
|
+
rows = torch.repeat_interleave(
|
|
83
|
+
torch.arange(len(users), device=home), counts, output_size=total
|
|
84
|
+
)
|
|
85
|
+
offsets = torch.arange(total, device=home) - torch.repeat_interleave(
|
|
86
|
+
torch.cumsum(counts, 0) - counts, counts, output_size=total
|
|
87
|
+
)
|
|
88
|
+
columns = self.indices[starts[rows] + offsets].long()
|
|
89
|
+
|
|
90
|
+
target = predictions.device
|
|
91
|
+
predictions[rows.to(target), columns.to(target)] = -torch.inf
|
|
92
|
+
|
|
93
|
+
|
|
23
94
|
def mask_seen_in_context(
|
|
24
95
|
predictions: Tensor,
|
|
25
96
|
user_indices: Tensor,
|
|
@@ -330,48 +401,34 @@ def top_k_breaking_ties(
|
|
|
330
401
|
|
|
331
402
|
return values, indices
|
|
332
403
|
|
|
333
|
-
rows = ambiguous.nonzero(as_tuple=True)[0]
|
|
334
|
-
scores = predictions if rows.numel() == predictions.size(0) else predictions[rows]
|
|
335
|
-
|
|
336
|
-
# The k-th score splits each row in three: the items above it are in the
|
|
337
|
-
# list whatever the draw, the items below it are out, and the items equal to
|
|
338
|
-
# it compete for the places left.
|
|
339
|
-
kth = values[rows, k - 1 :]
|
|
340
|
-
|
|
341
|
-
# Drawing the keys is the dominant cost, so they are drawn only for the
|
|
342
|
-
# items that can still make some list. When the ties sit on a known
|
|
343
|
-
# population, such as the cold items of a cold-start run, that is a small
|
|
344
|
-
# fraction of the catalogue. When it is most of it, narrowing would only
|
|
345
|
-
# add a copy of the scores.
|
|
346
|
-
columns = (scores >= kth).any(dim=0).nonzero(as_tuple=True)[0]
|
|
347
|
-
narrowed = columns.numel() <= scores.size(1) // 2
|
|
348
|
-
if narrowed:
|
|
349
|
-
scores = scores[:, columns]
|
|
350
|
-
|
|
351
|
-
# Keying the items above the k-th score over every random key, and the ones
|
|
352
|
-
# below it under, lets one top-k make the choice for every row at once, with
|
|
353
|
-
# a fresh key per user and item. Drawn where the generator lives, which
|
|
354
|
-
# torch requires, then moved to the scores: the evaluator's generator is on
|
|
355
|
-
# the CPU even when the scores are not.
|
|
356
|
-
keys = torch.rand(scores.shape, generator=generator, device=generator.device).to(
|
|
357
|
-
predictions.device
|
|
358
|
-
)
|
|
359
|
-
keys.masked_fill_(scores < kth, -1.0)
|
|
360
|
-
keys[scores > kth] += 2.0
|
|
361
|
-
_, chosen = torch.topk(keys, k, dim=1)
|
|
362
|
-
del keys
|
|
363
|
-
|
|
364
|
-
# The draw settled which items are in, and in key order. Sorting them by
|
|
365
|
-
# score, stably, puts a higher score first and leaves equal scores in the
|
|
366
|
-
# order their keys drew.
|
|
367
|
-
tied_values, order = torch.sort(
|
|
368
|
-
scores.gather(1, chosen), dim=1, descending=True, stable=True
|
|
369
|
-
)
|
|
370
|
-
chosen = chosen.gather(1, order)
|
|
371
|
-
if narrowed:
|
|
372
|
-
chosen = columns[chosen]
|
|
373
404
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
405
|
+
def rank_top_k(
|
|
406
|
+
predictions: Tensor,
|
|
407
|
+
k: int,
|
|
408
|
+
generator: Optional[torch.Generator] = None,
|
|
409
|
+
user_indices: Optional[Tensor] = None,
|
|
410
|
+
reranker: Optional["Reranker"] = None,
|
|
411
|
+
) -> Tuple[Tensor, Tensor]:
|
|
412
|
+
"""The list a ranking hands back: its top k, re-ranked when one is configured.
|
|
413
|
+
|
|
414
|
+
Evaluation, the recommendations a run writes and the answers a server gives
|
|
415
|
+
all end here once their scores are masked, so the three rank alike: ties
|
|
416
|
+
are broken per user from the same seed, and the same re-ranker reorders the
|
|
417
|
+
same pool.
|
|
418
|
+
|
|
419
|
+
Args:
|
|
420
|
+
predictions (Tensor): The masked score matrix, one row per user.
|
|
421
|
+
k (int): The cutoff.
|
|
422
|
+
generator (Optional[torch.Generator]): The generator whose seed breaks
|
|
423
|
+
ties, as in ``top_k_breaking_ties``.
|
|
424
|
+
user_indices (Optional[Tensor]): The user of each row, which keys the
|
|
425
|
+
tie break and tells a re-ranker whose history to read.
|
|
426
|
+
reranker (Optional[Reranker]): The re-ranker, or None to rank by score.
|
|
427
|
+
|
|
428
|
+
Returns:
|
|
429
|
+
Tuple[Tensor, Tensor]: The top-k values and the item indices they belong
|
|
430
|
+
to, in the order they are recommended.
|
|
431
|
+
"""
|
|
432
|
+
if reranker is not None:
|
|
433
|
+
return reranker(predictions, k, user_indices, generator)
|
|
434
|
+
return top_k_breaking_ties(predictions, k, generator, user_indices)
|
|
@@ -15,9 +15,9 @@ from tqdm import tqdm
|
|
|
15
15
|
|
|
16
16
|
from warprec.errors import ConfigurationError, DataError
|
|
17
17
|
from warprec.data.ranking import (
|
|
18
|
-
|
|
18
|
+
SeenItems,
|
|
19
|
+
rank_top_k,
|
|
19
20
|
resolve_recommendation_mask,
|
|
20
|
-
top_k_breaking_ties,
|
|
21
21
|
)
|
|
22
22
|
from warprec.data import Dataset
|
|
23
23
|
from warprec.recommenders.base_recommender import (
|
|
@@ -250,13 +250,13 @@ class Writer(ABC):
|
|
|
250
250
|
train_sparse = dataset.train_set.get_sparse()
|
|
251
251
|
umap_i, imap_i = dataset.get_inverse_mappings()
|
|
252
252
|
num_users = train_sparse.shape[0]
|
|
253
|
+
seen = SeenItems(train_sparse, model.device) if policy != "none" else None
|
|
253
254
|
all_user_indices = torch.arange(num_users, device=model.device)
|
|
254
255
|
batch_size = dataset.batch_size
|
|
255
256
|
|
|
256
257
|
batch_iterator = range(0, num_users, batch_size)
|
|
257
258
|
for i in tqdm(batch_iterator, desc="Generating recommendation batches"):
|
|
258
259
|
user_indices = all_user_indices[i : i + batch_size]
|
|
259
|
-
train_batch = train_sparse[user_indices.tolist(), :]
|
|
260
260
|
|
|
261
261
|
user_seq, seq_len = (
|
|
262
262
|
dataset.train_session.get_user_history_sequences(
|
|
@@ -272,18 +272,13 @@ class Writer(ABC):
|
|
|
272
272
|
user_seq=user_seq,
|
|
273
273
|
seq_len=seq_len,
|
|
274
274
|
)
|
|
275
|
-
if
|
|
276
|
-
|
|
275
|
+
if seen is not None:
|
|
276
|
+
seen.mask(predictions, user_indices)
|
|
277
277
|
# Ties are broken as the evaluator breaks them, from the same
|
|
278
278
|
# seed and per user, so the list written is the list evaluated.
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
)
|
|
283
|
-
else:
|
|
284
|
-
top_k_scores, top_k_items = top_k_breaking_ties(
|
|
285
|
-
predictions, k, tie_break, user_indices
|
|
286
|
-
)
|
|
279
|
+
top_k_scores, top_k_items = rank_top_k(
|
|
280
|
+
predictions, k, tie_break, user_indices, reranker
|
|
281
|
+
)
|
|
287
282
|
|
|
288
283
|
batch_users = user_indices.unsqueeze(1).expand(-1, k).flatten()
|
|
289
284
|
user_labels = [umap_i[idx.item()] for idx in batch_users]
|
|
@@ -437,8 +432,8 @@ class Writer(ABC):
|
|
|
437
432
|
has seen and, for a sequential model, their recent history - is
|
|
438
433
|
saved alongside, so that the file alone can be served.
|
|
439
434
|
training (Optional[Dict[str, Any]]): What the run knows about the
|
|
440
|
-
training - the dataset name, the evaluation strategy and
|
|
441
|
-
results - saved with the serving data so a server can describe
|
|
435
|
+
training - the dataset name, the evaluation strategy and seed and
|
|
436
|
+
the test results - saved with the serving data so a server can describe
|
|
442
437
|
the model. Used only together with the dataset.
|
|
443
438
|
"""
|
|
444
439
|
path = self._path_join(
|
|
@@ -13,10 +13,10 @@ from warprec.data.stash import METRIC_ARGUMENTS, check_stash
|
|
|
13
13
|
from warprec.data.ranking import (
|
|
14
14
|
cold_item_candidates,
|
|
15
15
|
mask_seen_in_context,
|
|
16
|
-
|
|
16
|
+
SeenItems,
|
|
17
|
+
rank_top_k,
|
|
17
18
|
resolve_mask_policy,
|
|
18
19
|
restrict_to_candidates,
|
|
19
|
-
top_k_breaking_ties,
|
|
20
20
|
)
|
|
21
21
|
from warprec.evaluation.metrics.base_metric import BaseMetric
|
|
22
22
|
from warprec.recommenders.base_recommender import (
|
|
@@ -111,6 +111,10 @@ class Evaluator:
|
|
|
111
111
|
|
|
112
112
|
self.reranker = reranker
|
|
113
113
|
self.candidate_mask = cold_item_candidates(train_set, candidates)
|
|
114
|
+
|
|
115
|
+
# Built on the first evaluation, on its device, and kept for the next
|
|
116
|
+
self._seen: Optional[SeenItems] = None
|
|
117
|
+
self._seen_for: Optional[Tuple[int, str]] = None
|
|
114
118
|
if self.candidate_mask is not None:
|
|
115
119
|
pool = int(self.candidate_mask.sum())
|
|
116
120
|
if pool == 0:
|
|
@@ -324,7 +328,6 @@ class Evaluator:
|
|
|
324
328
|
candidates = batch_data.get("candidates") # Optional (Sampled only)
|
|
325
329
|
|
|
326
330
|
# Prepare the model input
|
|
327
|
-
train_batch = train_sparse[user_indices.tolist(), :]
|
|
328
331
|
predict_kwargs = {"user_indices": user_indices}
|
|
329
332
|
|
|
330
333
|
# A. Sequential Models Support
|
|
@@ -388,7 +391,9 @@ class Evaluator:
|
|
|
388
391
|
batch_data.get("target_item"),
|
|
389
392
|
)
|
|
390
393
|
else:
|
|
391
|
-
|
|
394
|
+
self._seen_items(train_sparse, device).mask(
|
|
395
|
+
predictions, user_indices
|
|
396
|
+
)
|
|
392
397
|
|
|
393
398
|
elif strategy == "sampled":
|
|
394
399
|
# Mask seen items
|
|
@@ -412,6 +417,22 @@ class Evaluator:
|
|
|
412
417
|
if verbose:
|
|
413
418
|
self._log_results(eval_start_time, model.name)
|
|
414
419
|
|
|
420
|
+
def _seen_items(self, train_sparse: csr_matrix, device: Any) -> SeenItems:
|
|
421
|
+
"""The items each user has seen, on the device the scores are on.
|
|
422
|
+
|
|
423
|
+
Args:
|
|
424
|
+
train_sparse (csr_matrix): The training matrix of the evaluated dataset.
|
|
425
|
+
device (Any): The evaluation device.
|
|
426
|
+
|
|
427
|
+
Returns:
|
|
428
|
+
SeenItems: The seen items, built once per matrix and device.
|
|
429
|
+
"""
|
|
430
|
+
key = (id(train_sparse), str(device))
|
|
431
|
+
if self._seen is None or self._seen_for != key:
|
|
432
|
+
self._seen = SeenItems(train_sparse, device)
|
|
433
|
+
self._seen_for = key
|
|
434
|
+
return self._seen
|
|
435
|
+
|
|
415
436
|
def _sampled_candidates(
|
|
416
437
|
self, batch_data: Dict[str, Any], padding_idx: int
|
|
417
438
|
) -> Tuple[Tensor, Tensor]:
|
|
@@ -549,14 +570,9 @@ class Evaluator:
|
|
|
549
570
|
]
|
|
550
571
|
):
|
|
551
572
|
max_k = max(self.k_values)
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
)
|
|
556
|
-
else:
|
|
557
|
-
top_k_values_full, top_k_indices_full = top_k_breaking_ties(
|
|
558
|
-
predictions, max_k, self.tie_g, user_indices
|
|
559
|
-
)
|
|
573
|
+
top_k_values_full, top_k_indices_full = rank_top_k(
|
|
574
|
+
predictions, max_k, self.tie_g, user_indices, self.reranker
|
|
575
|
+
)
|
|
560
576
|
|
|
561
577
|
for k in self.k_values:
|
|
562
578
|
required = self.required_blocks.get(k, set())
|
|
@@ -8,7 +8,6 @@ import ray
|
|
|
8
8
|
from warprec.errors import (
|
|
9
9
|
CheckpointError,
|
|
10
10
|
ClusterError,
|
|
11
|
-
ConfigurationError,
|
|
12
11
|
RunStateError,
|
|
13
12
|
)
|
|
14
13
|
import warprec
|
|
@@ -19,14 +18,12 @@ from warprec.common import (
|
|
|
19
18
|
run_fingerprint,
|
|
20
19
|
warprec_version,
|
|
21
20
|
)
|
|
22
|
-
from warprec.data import Dataset
|
|
23
21
|
from warprec.data.timing import DataPreparationTimes
|
|
24
22
|
from warprec.evaluation.statistical_significance import compute_paired_statistical_test
|
|
25
23
|
from warprec.data.reader import ReaderFactory
|
|
26
24
|
from warprec.data.reader.base_reader import Reader
|
|
27
25
|
from warprec.data.writer import WriterFactory
|
|
28
26
|
from warprec.data.writer.base_writer import Writer
|
|
29
|
-
from warprec.recommenders.base_recommender import Recommender
|
|
30
27
|
from warprec.utils.callback import WarpRecCallback
|
|
31
28
|
from warprec.utils.config import (
|
|
32
29
|
RecomModel,
|
|
@@ -34,7 +31,7 @@ from warprec.utils.config import (
|
|
|
34
31
|
load_callback,
|
|
35
32
|
load_train_configuration,
|
|
36
33
|
)
|
|
37
|
-
from warprec.pipelines.remotes import remote_data_preparation
|
|
34
|
+
from warprec.pipelines.remotes import DataLayout, remote_data_preparation
|
|
38
35
|
from warprec.utils.enums import ResumeMode
|
|
39
36
|
from warprec.utils.logger import logger
|
|
40
37
|
|
|
@@ -313,126 +310,159 @@ def measure_emissions(context: PipelineContext) -> AbstractContextManager[Any]:
|
|
|
313
310
|
)
|
|
314
311
|
|
|
315
312
|
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
313
|
+
@dataclass
|
|
314
|
+
class PreparedDatasets:
|
|
315
|
+
"""The datasets of a run, as references to the objects the cluster holds.
|
|
316
|
+
|
|
317
|
+
The driver never fetches them: the trials, the model tasks and the swarm's
|
|
318
|
+
orchestrators receive the references, and Ray hands each task the datasets
|
|
319
|
+
it is given from the object store, without serializing them again.
|
|
320
|
+
|
|
321
|
+
Attributes:
|
|
322
|
+
main (ray.ObjectRef): The main dataset, the train/test split.
|
|
323
|
+
validation (ray.ObjectRef): The validation dataset, a reference to None
|
|
324
|
+
without one.
|
|
325
|
+
folds (ray.ObjectRef): The list of cross-validation folds, empty
|
|
326
|
+
without them.
|
|
327
|
+
layout (DataLayout): How the data was split, and the preparation times.
|
|
328
|
+
"""
|
|
329
|
+
|
|
330
|
+
main: ray.ObjectRef
|
|
331
|
+
validation: ray.ObjectRef
|
|
332
|
+
folds: ray.ObjectRef
|
|
333
|
+
layout: DataLayout
|
|
334
|
+
|
|
335
|
+
@property
|
|
336
|
+
def cross_validated(self) -> bool:
|
|
337
|
+
"""Whether the models are searched over cross-validation folds.
|
|
338
|
+
|
|
339
|
+
Returns:
|
|
340
|
+
bool: True when there are folds and no validation split.
|
|
341
|
+
"""
|
|
342
|
+
return not self.layout.has_validation and self.layout.n_folds > 0
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
def prepare_datasets(context: PipelineContext) -> PreparedDatasets:
|
|
319
346
|
"""Build the datasets on the Ray cluster, and write the splits if asked to.
|
|
320
347
|
|
|
321
348
|
Args:
|
|
322
349
|
context (PipelineContext): The context produced by the bootstrap.
|
|
323
350
|
|
|
324
351
|
Returns:
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
Raises:
|
|
330
|
-
ConfigurationError: If the configured split file format is not supported.
|
|
352
|
+
PreparedDatasets: References to the main dataset, the validation dataset
|
|
353
|
+
and the cross-validation folds, and how the task preparing them
|
|
354
|
+
split the data and spent its time.
|
|
331
355
|
"""
|
|
332
356
|
config = context.config
|
|
333
357
|
cpu_data_prep = config.general.cpu_data_prep
|
|
334
358
|
custom_res_data_prep = config.general.custom_resources_data_prep
|
|
335
359
|
label_selector_data_prep = config.general.label_selector_data_prep
|
|
336
360
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
361
|
+
# Four returns, so that each dataset is an object of its own
|
|
362
|
+
refs: List[ray.ObjectRef] = remote_data_preparation.options( # type: ignore[assignment]
|
|
363
|
+
num_cpus=cpu_data_prep,
|
|
364
|
+
num_returns=4,
|
|
365
|
+
resources=custom_res_data_prep if custom_res_data_prep else None,
|
|
366
|
+
label_selector=label_selector_data_prep if label_selector_data_prep else None,
|
|
367
|
+
).remote(
|
|
368
|
+
reader=context.reader,
|
|
369
|
+
callback=context.callback,
|
|
370
|
+
config=config,
|
|
371
|
+
writer=context.writer,
|
|
372
|
+
) # type: ignore[call-arg]
|
|
373
|
+
|
|
374
|
+
main_ref, val_ref, folds_ref, layout_ref = refs
|
|
375
|
+
|
|
376
|
+
# Only the layout comes to the driver; the datasets stay where they are
|
|
377
|
+
return PreparedDatasets(
|
|
378
|
+
main=main_ref, validation=val_ref, folds=folds_ref, layout=ray.get(layout_ref)
|
|
349
379
|
)
|
|
350
380
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
381
|
+
|
|
382
|
+
def model_task_options(
|
|
383
|
+
params: RecomModel, config: TrainConfiguration
|
|
384
|
+
) -> Tuple[str, Dict[str, Any]]:
|
|
385
|
+
"""The device and the resources of the task that completes a model.
|
|
386
|
+
|
|
387
|
+
Args:
|
|
388
|
+
params (RecomModel): The parameters of the model.
|
|
389
|
+
config (TrainConfiguration): The configuration of the experiment.
|
|
390
|
+
|
|
391
|
+
Returns:
|
|
392
|
+
Tuple[str, Dict[str, Any]]: The device, and the options of the Ray task.
|
|
393
|
+
"""
|
|
394
|
+
general_device = config.general.device
|
|
395
|
+
model_device = params.optimization.device
|
|
396
|
+
device = general_device if model_device is None else model_device
|
|
397
|
+
|
|
398
|
+
num_gpus = params.optimization.gpu_per_trial
|
|
399
|
+
# A model on cuda without GPUs requested still needs a node that has one
|
|
400
|
+
if device == "cuda" and num_gpus == 0:
|
|
401
|
+
num_gpus = 1
|
|
402
|
+
|
|
403
|
+
custom_res = params.optimization.custom_resources_per_trial or {}
|
|
404
|
+
label_selector = params.optimization.label_selector or {}
|
|
405
|
+
return device, {
|
|
406
|
+
"num_cpus": params.optimization.cpu_per_trial,
|
|
407
|
+
"num_gpus": num_gpus,
|
|
408
|
+
"resources": custom_res if custom_res else None,
|
|
409
|
+
"label_selector": label_selector if label_selector else None,
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
|
|
413
|
+
def callback_needs_model(callback: WarpRecCallback) -> bool:
|
|
414
|
+
"""Whether a callback receives the best model, so the driver must fetch it.
|
|
415
|
+
|
|
416
|
+
Only the hooks that receive the model count, and only when the callback
|
|
417
|
+
overrides them: otherwise the model never leaves the cluster.
|
|
418
|
+
|
|
419
|
+
Args:
|
|
420
|
+
callback (WarpRecCallback): The callback of the run.
|
|
421
|
+
|
|
422
|
+
Returns:
|
|
423
|
+
bool: True when it overrides 'on_training_complete' or
|
|
424
|
+
'on_evaluation_complete'.
|
|
425
|
+
"""
|
|
426
|
+
return any(
|
|
427
|
+
getattr(type(callback), hook) is not getattr(WarpRecCallback, hook)
|
|
428
|
+
for hook in ("on_training_complete", "on_evaluation_complete")
|
|
429
|
+
)
|
|
374
430
|
|
|
375
431
|
|
|
376
432
|
def write_model_outputs(
|
|
377
433
|
context: PipelineContext,
|
|
378
434
|
model_name: str,
|
|
379
|
-
params: RecomModel,
|
|
380
|
-
model: Recommender,
|
|
381
435
|
results: Dict[Any, Any],
|
|
436
|
+
best_params: Dict[str, Any],
|
|
382
437
|
best_iter: int,
|
|
383
|
-
dataset: Dataset,
|
|
384
438
|
) -> None:
|
|
385
|
-
"""Write what
|
|
439
|
+
"""Write what the driver keeps of one evaluated model.
|
|
386
440
|
|
|
387
441
|
The train and swarm pipelines both call this once a model is evaluated, so
|
|
388
|
-
that either of them leaves the same files behind: the overall and
|
|
389
|
-
|
|
390
|
-
|
|
442
|
+
that either of them leaves the same files behind: the overall results and
|
|
443
|
+
the best parameters. The per-user results, the model and its
|
|
444
|
+
recommendations are written on the cluster, by the task that evaluated it.
|
|
391
445
|
|
|
392
446
|
Args:
|
|
393
447
|
context (PipelineContext): The context produced by the bootstrap.
|
|
394
448
|
model_name (str): The name of the model.
|
|
395
|
-
params (RecomModel): The parameters of the model.
|
|
396
|
-
model (Recommender): The best model found.
|
|
397
449
|
results (Dict[Any, Any]): The evaluation results of the model.
|
|
450
|
+
best_params (Dict[str, Any]): The hyperparameters of the best model.
|
|
398
451
|
best_iter (int): The best training iteration.
|
|
399
|
-
dataset (Dataset): The main dataset the model was evaluated on.
|
|
400
452
|
"""
|
|
401
453
|
config = context.config
|
|
402
454
|
writer = context.writer
|
|
403
455
|
|
|
404
456
|
writer.write_results(results, model_name, **config.writer.results.model_dump())
|
|
405
|
-
|
|
406
|
-
if config.evaluation.save_per_user:
|
|
407
|
-
i_umap, _ = dataset.get_inverse_mappings()
|
|
408
|
-
writer.write_results_per_user(
|
|
409
|
-
results, model_name, i_umap, **config.writer.results.model_dump()
|
|
410
|
-
)
|
|
411
|
-
|
|
412
457
|
writer.write_params(
|
|
413
458
|
{
|
|
414
459
|
model_name: {
|
|
415
|
-
"Best Params":
|
|
460
|
+
"Best Params": best_params,
|
|
416
461
|
"Best Training Iteration": best_iter,
|
|
417
462
|
}
|
|
418
463
|
}
|
|
419
464
|
)
|
|
420
465
|
|
|
421
|
-
# Model serialization, with what serving needs from the data
|
|
422
|
-
if params.meta.save_model:
|
|
423
|
-
evaluation: Dict[str, Any] = {"strategy": config.evaluation.strategy}
|
|
424
|
-
if config.evaluation.strategy == "sampled":
|
|
425
|
-
evaluation["num_negatives"] = config.evaluation.num_negatives
|
|
426
|
-
writer.write_model(
|
|
427
|
-
model,
|
|
428
|
-
dataset=dataset,
|
|
429
|
-
training={
|
|
430
|
-
"dataset": config.writer.dataset_name,
|
|
431
|
-
"evaluation": evaluation,
|
|
432
|
-
"metrics": results,
|
|
433
|
-
},
|
|
434
|
-
)
|
|
435
|
-
|
|
436
466
|
|
|
437
467
|
def raise_failed_loads(model_names: List[str], run_name: str) -> None:
|
|
438
468
|
"""End a run whose searches finished but some best models could not be built.
|