warprec 2.2.6__tar.gz → 2.2.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.2.6 → warprec-2.2.8}/PKG-INFO +1 -1
- {warprec-2.2.6 → warprec-2.2.8}/pyproject.toml +1 -1
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/entities/sessions.py +30 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/ranking.py +69 -1
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/writer/base_writer.py +4 -4
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/evaluator.py +24 -3
- {warprec-2.2.6 → warprec-2.2.8}/warprec/pipelines/common.py +19 -1
- {warprec-2.2.6 → warprec-2.2.8}/warprec/pipelines/estimate.py +3 -3
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/callbacks.py +20 -5
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/trainer/search_algorithm_wrapper.py +154 -2
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/trainer/trainer.py +9 -0
- {warprec-2.2.6 → warprec-2.2.8}/LICENSE +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/README.md +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/common/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/common/initialize.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/common/run_state.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/common/std_logs.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/dataset.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/entities/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/entities/common.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/entities/context.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/entities/interactions.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/entities/knowledge.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/entities/multimodal.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/entities/train_structures/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/entities/train_structures/custom_collate_fn.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/entities/train_structures/interaction_structures.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/entities/train_structures/session_structures.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/entities/transactions.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/eval_loaders.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/filtering.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/reader/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/reader/azureblob_reader.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/reader/base_reader.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/reader/local_reader.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/schema.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/splitting/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/splitting/splitter.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/splitting/strategies.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/stash.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/timing.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/writer/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/writer/azureblob_writer.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/data/writer/local_writer.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/errors.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/factory.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/accuracy/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/accuracy/auc.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/accuracy/f1.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/accuracy/gauc.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/accuracy/hit_rate.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/accuracy/lauc.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/accuracy/logloss.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/accuracy/map.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/accuracy/mar.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/accuracy/mrr.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/accuracy/ndcg.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/accuracy/precision.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/accuracy/recall.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/base_metric.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/bias/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/bias/aclt.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/bias/aplt.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/bias/arp.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/bias/long_tail.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/bias/pop_reo.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/bias/pop_rsp.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/coverage/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/coverage/item_coverage.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/coverage/numretrieved.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/coverage/user_coverage.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/coverage/user_coverage_at_n.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/debiased/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/debiased/base.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/debiased/dcg.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/debiased/recall.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/diversity/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/diversity/gini_index.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/diversity/shannon_entropy.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/diversity/srecall.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/fairness/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/fairness/biasdisparitybd.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/fairness/biasdisparitybr.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/fairness/biasdisparitybs.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/fairness/itemmadranking.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/fairness/itemmadrating.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/fairness/reo.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/fairness/rsp.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/fairness/usermadranking.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/fairness/usermadrating.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/multiobjective/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/multiobjective/euclideandistance.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/multiobjective/hypervolume.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/novelty/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/novelty/efd.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/novelty/epc.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/novelty/novelty_profile.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/rating/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/rating/mae.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/rating/mse.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/metrics/rating/rmse.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/propensity.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/evaluation/statistical_significance.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/pipelines/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/pipelines/design.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/pipelines/eval.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/pipelines/remotes/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/pipelines/remotes/data.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/pipelines/remotes/ml.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/pipelines/swarm.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/pipelines/train.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/base_recommender.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/cdae.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/diffrec.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/ease.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/elsa.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/macridvae.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/multidae.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/multivae.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/sansa.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/dgcf.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/egcf.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/esigcf.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/gcmc.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/graph_utils.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightccf.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgcl.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgcn.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgcnpp.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgode.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/macrgcn.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/mixrec.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/ngcf.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/paac.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/popdcl.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/recdcl.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/rp3beta.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/sgcl.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/sgl.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/simgcl.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/simrec.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/ultragcn.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/graph_based/xsimgcl.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/knn/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/knn/itemknn.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/knn/itemknntd.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/knn/userknn.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/knn/userknntd.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/admmslim.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/bpr.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/fism.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/ials.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/ials2008.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/macrmf.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/slim.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/neural/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/neural/convncf.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/neural/neumf.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/collaborative_filtering_recommender/neural/twotower.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/content_based_recommender/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/content_based_recommender/vsm.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/context_aware_recommender/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/context_aware_recommender/afm.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/context_aware_recommender/dcn.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/context_aware_recommender/dcnv2.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/context_aware_recommender/deepfm.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/context_aware_recommender/fm.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/context_aware_recommender/nfm.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/context_aware_recommender/wideanddeep.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/context_aware_recommender/xdeepfm.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/hybrid_recommender/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/hybrid_recommender/addease.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/hybrid_recommender/attributeitemknn.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/hybrid_recommender/attributeuserknn.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/hybrid_recommender/cease.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/knowledge_aware_recommender/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/knowledge_aware_recommender/cke.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/knowledge_aware_recommender/kahfm.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/knowledge_aware_recommender/kgat.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/knowledge_aware_recommender/kgcn.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/knowledge_aware_recommender/kgflex.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/knowledge_aware_recommender/kgin.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/knowledge_aware_recommender/knowledge_utils.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/knowledge_aware_recommender/ripplenet.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/layers.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/losses.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/lr_scheduler_wrapper.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/multimodal_recommender/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/multimodal_recommender/bm3.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/multimodal_recommender/freedom.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/multimodal_recommender/lattice.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/multimodal_recommender/mgcn.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/multimodal_recommender/mmgcn.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/multimodal_recommender/multimodal_utils.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/multimodal_recommender/vbpr.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/optimizer_wrapper.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/proxy.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/reranking/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/reranking/base.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/reranking/calibration.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/reranking/factory.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/reranking/mmr.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/sequential_recommender/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/sequential_recommender/bert4rec.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/sequential_recommender/bsarec.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/sequential_recommender/caser.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/sequential_recommender/cl4srec.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/sequential_recommender/core.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/sequential_recommender/duorec.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/sequential_recommender/esasrec.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/sequential_recommender/fossil.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/sequential_recommender/gru4rec.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/sequential_recommender/gsasrec.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/sequential_recommender/lightsans.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/sequential_recommender/linrec.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/sequential_recommender/narm.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/sequential_recommender/sasrec.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/sequential_recommender/stan.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/similarities.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/trainer/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/trainer/dashboard_callbacks.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/trainer/emissions.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/trainer/logger_callbacks.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/trainer/objectives.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/trainer/runtime.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/trainer/scheduler_wrapper.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/trainer/timing.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/unpersonalized_recommender/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/unpersonalized_recommender/pop.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/recommenders/unpersonalized_recommender/random.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/run.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/serve.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/serving/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/serving/api.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/serving/app.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/serving/catalogue.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/serving/context.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/serving/deployments.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/serving/errors.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/serving/mcp.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/serving/payload.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/serving/schemas.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/serving/servable.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/callback.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/config/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/config/common.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/config/config.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/config/dashboard_configuration.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/config/estimate_configuration.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/config/evaluation_configuration.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/config/general_configuration.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/config/model_configuration.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/config/reader_configuration.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/config/recommender_model_config/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/autoencoder_config.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/graph_based_config.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/knn_config.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/latent_factor_config.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/neural_config.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/config/recommender_model_config/content_based_config.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/config/recommender_model_config/context_aware_config.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/config/recommender_model_config/hybrid_config.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/config/recommender_model_config/knowledge_aware_config.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/config/recommender_model_config/multimodal_config.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/config/recommender_model_config/sequential_model_config.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/config/recommender_model_config/unpersonalized_config.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/config/rerank_configuration.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/config/run_configuration.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/config/search_space_wrapper.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/config/serving_configuration.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/config/splitter_configuration.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/config/training_configuration.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/config/writer_configuration.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/determinism.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/enums.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/helpers.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/logger/__init__.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/logger/logger.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/pause.py +0 -0
- {warprec-2.2.6 → warprec-2.2.8}/warprec/utils/registry.py +0 -0
|
@@ -206,6 +206,32 @@ class Sessions:
|
|
|
206
206
|
"No valid sequences found (min 2 interactions per user needed)."
|
|
207
207
|
)
|
|
208
208
|
|
|
209
|
+
def _keep_in_memory(self) -> None:
|
|
210
|
+
"""Copy the arrays the loaders read at random out of Ray's object store.
|
|
211
|
+
|
|
212
|
+
Fetched from the store they are read-only views, which Ray keeps on disk
|
|
213
|
+
when the store is full, so every sample would read the disk.
|
|
214
|
+
"""
|
|
215
|
+
|
|
216
|
+
def resident(array: Optional[np.ndarray]) -> Optional[np.ndarray]:
|
|
217
|
+
# Arrays the process can write are already its own
|
|
218
|
+
if array is None or array.flags.writeable:
|
|
219
|
+
return array
|
|
220
|
+
return array.copy()
|
|
221
|
+
|
|
222
|
+
self._flat_items = resident(self._flat_items)
|
|
223
|
+
self._flat_users = resident(self._flat_users)
|
|
224
|
+
self._user_offsets = resident(self._user_offsets)
|
|
225
|
+
self._valid_sample_indices = resident(self._valid_sample_indices)
|
|
226
|
+
|
|
227
|
+
# Negative sampling reads only the structure of the matrix
|
|
228
|
+
sparse = self._inter_sparse
|
|
229
|
+
if sparse is not None and not sparse.indices.flags.writeable:
|
|
230
|
+
self._inter_sparse = csr_matrix(
|
|
231
|
+
(sparse.data, sparse.indices.copy(), sparse.indptr.copy()),
|
|
232
|
+
shape=sparse.shape,
|
|
233
|
+
)
|
|
234
|
+
|
|
209
235
|
def get_sequential_dataloader(
|
|
210
236
|
self,
|
|
211
237
|
max_seq_len: int,
|
|
@@ -217,6 +243,7 @@ class Sessions:
|
|
|
217
243
|
**kwargs: Any,
|
|
218
244
|
) -> DataLoader:
|
|
219
245
|
"""Standard SASRec/RNN style dataloader (History -> Next Item)."""
|
|
246
|
+
self._keep_in_memory()
|
|
220
247
|
|
|
221
248
|
self._require_valid_targets()
|
|
222
249
|
|
|
@@ -251,6 +278,7 @@ class Sessions:
|
|
|
251
278
|
**kwargs: Any,
|
|
252
279
|
) -> DataLoader:
|
|
253
280
|
"""Sequential dataloader that also samples a same-target positive sequence."""
|
|
281
|
+
self._keep_in_memory()
|
|
254
282
|
|
|
255
283
|
self._require_valid_targets()
|
|
256
284
|
|
|
@@ -283,6 +311,7 @@ class Sessions:
|
|
|
283
311
|
**kwargs: Any,
|
|
284
312
|
) -> DataLoader:
|
|
285
313
|
"""Sequence-to-Sequence dataloader (Sliding Windows)."""
|
|
314
|
+
self._keep_in_memory()
|
|
286
315
|
|
|
287
316
|
# 1. Calculate Windows
|
|
288
317
|
user_lens = np.diff(self._user_offsets)
|
|
@@ -355,6 +384,7 @@ class Sessions:
|
|
|
355
384
|
**kwargs: Any,
|
|
356
385
|
) -> DataLoader:
|
|
357
386
|
"""BERT4Rec style dataloader (Masked Language Modeling)."""
|
|
387
|
+
self._keep_in_memory()
|
|
358
388
|
|
|
359
389
|
user_lens = np.diff(self._user_offsets)
|
|
360
390
|
valid_users = np.where(user_lens >= 2)[0]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import TYPE_CHECKING, 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
|
|
@@ -23,6 +23,74 @@ def mask_seen_pairs(predictions: Tensor, seen: csr_matrix) -> None:
|
|
|
23
23
|
predictions[seen.nonzero()] = -torch.inf
|
|
24
24
|
|
|
25
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
|
+
|
|
26
94
|
def mask_seen_in_context(
|
|
27
95
|
predictions: Tensor,
|
|
28
96
|
user_indices: Tensor,
|
|
@@ -15,7 +15,7 @@ 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
19
|
rank_top_k,
|
|
20
20
|
resolve_recommendation_mask,
|
|
21
21
|
)
|
|
@@ -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,8 +272,8 @@ 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
279
|
top_k_scores, top_k_items = rank_top_k(
|
|
@@ -13,7 +13,7 @@ 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
17
|
rank_top_k,
|
|
18
18
|
resolve_mask_policy,
|
|
19
19
|
restrict_to_candidates,
|
|
@@ -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]:
|
|
@@ -352,6 +352,9 @@ def prepare_datasets(context: PipelineContext) -> PreparedDatasets:
|
|
|
352
352
|
PreparedDatasets: References to the main dataset, the validation dataset
|
|
353
353
|
and the cross-validation folds, and how the task preparing them
|
|
354
354
|
split the data and spent its time.
|
|
355
|
+
|
|
356
|
+
Raises:
|
|
357
|
+
ClusterError: If Ray's memory monitor stops the data preparation.
|
|
355
358
|
"""
|
|
356
359
|
config = context.config
|
|
357
360
|
cpu_data_prep = config.general.cpu_data_prep
|
|
@@ -362,6 +365,10 @@ def prepare_datasets(context: PipelineContext) -> PreparedDatasets:
|
|
|
362
365
|
refs: List[ray.ObjectRef] = remote_data_preparation.options( # type: ignore[assignment]
|
|
363
366
|
num_cpus=cpu_data_prep,
|
|
364
367
|
num_returns=4,
|
|
368
|
+
# Ray retries a task its memory monitor kills without limit unless
|
|
369
|
+
# the task is not retried at all: the preparation would be killed
|
|
370
|
+
# and started again until the job's time ran out, without an error
|
|
371
|
+
max_retries=0,
|
|
365
372
|
resources=custom_res_data_prep if custom_res_data_prep else None,
|
|
366
373
|
label_selector=label_selector_data_prep if label_selector_data_prep else None,
|
|
367
374
|
).remote(
|
|
@@ -374,8 +381,19 @@ def prepare_datasets(context: PipelineContext) -> PreparedDatasets:
|
|
|
374
381
|
main_ref, val_ref, folds_ref, layout_ref = refs
|
|
375
382
|
|
|
376
383
|
# Only the layout comes to the driver; the datasets stay where they are
|
|
384
|
+
try:
|
|
385
|
+
layout = ray.get(layout_ref)
|
|
386
|
+
except ray.exceptions.OutOfMemoryError as error:
|
|
387
|
+
raise ClusterError(
|
|
388
|
+
"Ray's memory monitor stopped the data preparation, which needed "
|
|
389
|
+
"more memory than its node had left. The datasets are built in "
|
|
390
|
+
"the task's memory and then stored in Ray's object store, so on "
|
|
391
|
+
"the node both count: leave the object store at its default size "
|
|
392
|
+
"(it spills to disk), or prepare the data on a node with more "
|
|
393
|
+
f"memory (general.label_selector_data_prep). Ray's message: {error}"
|
|
394
|
+
) from error
|
|
377
395
|
return PreparedDatasets(
|
|
378
|
-
main=main_ref, validation=val_ref, folds=folds_ref, layout=
|
|
396
|
+
main=main_ref, validation=val_ref, folds=folds_ref, layout=layout
|
|
379
397
|
)
|
|
380
398
|
|
|
381
399
|
|
|
@@ -16,7 +16,7 @@ from warprec.data.timing import DataPreparationTimes
|
|
|
16
16
|
from warprec.data import Dataset
|
|
17
17
|
from warprec.data.ranking import (
|
|
18
18
|
mask_seen_in_context,
|
|
19
|
-
|
|
19
|
+
SeenItems,
|
|
20
20
|
resolve_mask_policy,
|
|
21
21
|
restrict_to_candidates,
|
|
22
22
|
)
|
|
@@ -387,6 +387,7 @@ def _estimate_eval_loop( # noqa: PLR0912, PLR0915
|
|
|
387
387
|
batch_times: List[float] = []
|
|
388
388
|
train_sparse = dataset.train_set.get_sparse()
|
|
389
389
|
padding_idx = train_sparse.shape[1]
|
|
390
|
+
seen = SeenItems(train_sparse, device)
|
|
390
391
|
max_batches = warmup_batches + measured_batches
|
|
391
392
|
|
|
392
393
|
# The batches are run here rather than through Evaluator.evaluate so that
|
|
@@ -412,7 +413,6 @@ def _estimate_eval_loop( # noqa: PLR0912, PLR0915
|
|
|
412
413
|
context = batch_data.get("context")
|
|
413
414
|
candidates = batch_data.get("candidates")
|
|
414
415
|
|
|
415
|
-
train_batch = train_sparse[user_indices.tolist(), :]
|
|
416
416
|
predict_kwargs = {"user_indices": user_indices}
|
|
417
417
|
|
|
418
418
|
if isinstance(model, SequentialRecommenderUtils):
|
|
@@ -468,7 +468,7 @@ def _estimate_eval_loop( # noqa: PLR0912, PLR0915
|
|
|
468
468
|
batch_data.get("target_item"),
|
|
469
469
|
)
|
|
470
470
|
else:
|
|
471
|
-
|
|
471
|
+
seen.mask(predictions, user_indices)
|
|
472
472
|
else:
|
|
473
473
|
predictions[candidates == padding_idx] = -torch.inf
|
|
474
474
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import random
|
|
3
|
-
from typing import Any, Dict, Iterator, Optional, Tuple
|
|
3
|
+
from typing import Any, Dict, Iterator, List, Optional, Tuple
|
|
4
4
|
|
|
5
5
|
import numpy as np
|
|
6
6
|
import psutil
|
|
7
7
|
import torch
|
|
8
|
+
import torch.distributed as dist
|
|
8
9
|
import lightning as L
|
|
9
10
|
from ray import train
|
|
10
11
|
from torch import Tensor
|
|
@@ -464,7 +465,7 @@ class RandomStateCallback(L.Callback):
|
|
|
464
465
|
for config in trainer.lr_scheduler_configs
|
|
465
466
|
if config.reduce_on_plateau and config.monitor in trainer.callback_metrics
|
|
466
467
|
}
|
|
467
|
-
|
|
468
|
+
state = {
|
|
468
469
|
"python": random.getstate(),
|
|
469
470
|
"numpy": np.random.get_state(),
|
|
470
471
|
"torch": torch.get_rng_state(),
|
|
@@ -480,6 +481,16 @@ class RandomStateCallback(L.Callback):
|
|
|
480
481
|
"plateau": plateau,
|
|
481
482
|
}
|
|
482
483
|
|
|
484
|
+
# Every rank draws from its own generators, but only the first writes
|
|
485
|
+
# the checkpoint: each rank's state is gathered for it to keep. Every
|
|
486
|
+
# rank dumps the checkpoint, so all of them take part in the gather.
|
|
487
|
+
if trainer.world_size > 1 and dist.is_available() and dist.is_initialized():
|
|
488
|
+
ranks: List[Any] = [None] * trainer.world_size
|
|
489
|
+
dist.all_gather_object(ranks, state)
|
|
490
|
+
checkpoint[RANDOM_STATE] = {"ranks": ranks}
|
|
491
|
+
else:
|
|
492
|
+
checkpoint[RANDOM_STATE] = state
|
|
493
|
+
|
|
483
494
|
def on_load_checkpoint(
|
|
484
495
|
self,
|
|
485
496
|
trainer: L.Trainer,
|
|
@@ -497,15 +508,19 @@ class RandomStateCallback(L.Callback):
|
|
|
497
508
|
checkpoint (Dict[str, Any]): The checkpoint being restored.
|
|
498
509
|
"""
|
|
499
510
|
state = checkpoint.get(RANDOM_STATE)
|
|
500
|
-
if state
|
|
511
|
+
saved_ranks = len(state["ranks"]) if state and "ranks" in state else 1
|
|
512
|
+
if state is None or saved_ranks != trainer.world_size:
|
|
501
513
|
if trainer.is_global_zero:
|
|
502
514
|
logger.attention(
|
|
503
515
|
"The checkpoint this trial resumes from carries no random "
|
|
504
516
|
"state it can restore (it predates WarpRec saving one, or "
|
|
505
|
-
"
|
|
506
|
-
"epochs will not draw the samples
|
|
517
|
+
"it was written by a trial training on another number of "
|
|
518
|
+
"workers), so the resumed epochs will not draw the samples "
|
|
519
|
+
"an uninterrupted run would."
|
|
507
520
|
)
|
|
508
521
|
return
|
|
522
|
+
if "ranks" in state:
|
|
523
|
+
state = state["ranks"][trainer.global_rank]
|
|
509
524
|
|
|
510
525
|
self._pending = state
|
|
511
526
|
loader = self.train_dataloader
|
|
@@ -10,34 +10,186 @@ Author: Avolio Marco
|
|
|
10
10
|
Date: 03/03/2025
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
import copy
|
|
14
|
+
from typing import Any, Dict, List, Optional
|
|
14
15
|
from abc import ABC, abstractmethod
|
|
15
16
|
|
|
16
17
|
from optuna.samplers import TPESampler
|
|
17
18
|
from ray.tune import Tuner
|
|
18
|
-
from ray.tune.search import ConcurrencyLimiter
|
|
19
|
+
from ray.tune.search import ConcurrencyLimiter, Searcher
|
|
20
|
+
from ray.tune.search.util import _set_search_properties_backwards_compatible
|
|
19
21
|
from ray.tune.search.basic_variant import BasicVariantGenerator
|
|
20
22
|
from ray.tune.search.hyperopt import HyperOptSearch
|
|
21
23
|
from ray.tune.search.optuna import OptunaSearch
|
|
22
24
|
from ray.tune.search.bohb import TuneBOHB
|
|
23
25
|
from warprec.utils.enums import SearchAlgorithms
|
|
26
|
+
from warprec.utils.helpers import model_param_from_dict
|
|
24
27
|
from warprec.utils.logger import logger
|
|
25
28
|
from warprec.utils.registry import search_algorithm_registry
|
|
26
29
|
|
|
27
30
|
|
|
31
|
+
def invalid_combination(
|
|
32
|
+
model_name: Optional[str], config: Dict[str, Any]
|
|
33
|
+
) -> Optional[str]:
|
|
34
|
+
"""Why a sampled combination of hyperparameters cannot be trained.
|
|
35
|
+
|
|
36
|
+
The check a trial makes before it builds its model, made before the trial
|
|
37
|
+
is launched: a model whose hyperparameters constrain each other (an
|
|
38
|
+
embedding size the number of attention heads must divide) refuses some of
|
|
39
|
+
the combinations its search space holds.
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
model_name (Optional[str]): The model searched, None to check nothing.
|
|
43
|
+
config (Dict[str, Any]): The sampled hyperparameters.
|
|
44
|
+
|
|
45
|
+
Returns:
|
|
46
|
+
Optional[str]: Why the combination is invalid, None when it is valid.
|
|
47
|
+
"""
|
|
48
|
+
if model_name is None:
|
|
49
|
+
return None
|
|
50
|
+
try:
|
|
51
|
+
params = model_param_from_dict(model_name, dict(config))
|
|
52
|
+
if params.need_single_trial_validation:
|
|
53
|
+
params.validate_single_trial_params()
|
|
54
|
+
except ValueError as error:
|
|
55
|
+
return str(error)
|
|
56
|
+
return None
|
|
57
|
+
|
|
58
|
+
|
|
28
59
|
class CappedVariantGenerator(BasicVariantGenerator):
|
|
29
60
|
"""Ray Tune's grid and random searcher, keeping the cap it was last given.
|
|
30
61
|
|
|
31
62
|
Ray restores a paused search's searcher with the cap it was paused with.
|
|
32
63
|
WarpRec computes the cap from the cluster as the search resumes, and sets
|
|
33
64
|
it on the restored searcher, which then keeps it.
|
|
65
|
+
|
|
66
|
+
Given a model name, it also skips the combinations of hyperparameters the
|
|
67
|
+
model refuses, instead of launching a trial that could only fail.
|
|
34
68
|
"""
|
|
35
69
|
|
|
70
|
+
model_name: Optional[str] = None
|
|
71
|
+
|
|
36
72
|
def set_state(self, state):
|
|
37
73
|
cap = self.max_concurrent
|
|
38
74
|
super().set_state(state)
|
|
39
75
|
self.max_concurrent = cap
|
|
40
76
|
|
|
77
|
+
def next_trial(self):
|
|
78
|
+
while True:
|
|
79
|
+
trial = super().next_trial()
|
|
80
|
+
if trial is None:
|
|
81
|
+
return None
|
|
82
|
+
reason = invalid_combination(self.model_name, trial.config)
|
|
83
|
+
if reason is None:
|
|
84
|
+
return trial
|
|
85
|
+
self._live_trials.discard(trial.trial_id)
|
|
86
|
+
logger.attention(
|
|
87
|
+
f"Skipped the combination {trial.config} of {self.model_name}, "
|
|
88
|
+
f"which cannot be trained: {reason}"
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class ValidSuggestions(Searcher):
|
|
93
|
+
"""A searcher that suggests only combinations the model can be trained with.
|
|
94
|
+
|
|
95
|
+
A combination the model refuses is reported to the searcher as a failed
|
|
96
|
+
trial, so that a model-based searcher learns to avoid it, and another is
|
|
97
|
+
asked for in its place, under an id of its own: a searcher answers the same
|
|
98
|
+
id with the same combination.
|
|
99
|
+
|
|
100
|
+
Args:
|
|
101
|
+
searcher (Searcher): The searcher to wrap.
|
|
102
|
+
model_name (str): The model searched.
|
|
103
|
+
|
|
104
|
+
Attributes:
|
|
105
|
+
MAX_ATTEMPTS (int): How many combinations to try before letting one
|
|
106
|
+
the model refuses through, to fail as a trial.
|
|
107
|
+
"""
|
|
108
|
+
|
|
109
|
+
MAX_ATTEMPTS: int = 100
|
|
110
|
+
|
|
111
|
+
def __init__(self, searcher: Searcher, model_name: str):
|
|
112
|
+
self.searcher = searcher
|
|
113
|
+
self.model_name = model_name
|
|
114
|
+
# The id the searcher knows each trial by, when it is not the trial's
|
|
115
|
+
self.inner_ids: Dict[str, str] = {}
|
|
116
|
+
super().__init__(metric=searcher.metric, mode=searcher.mode)
|
|
117
|
+
|
|
118
|
+
def _inner(self, trial_id: str) -> str:
|
|
119
|
+
return self.inner_ids.get(trial_id, trial_id)
|
|
120
|
+
|
|
121
|
+
def set_search_properties(
|
|
122
|
+
self, metric: Optional[str], mode: Optional[str], config: Dict, **spec: Any
|
|
123
|
+
) -> bool:
|
|
124
|
+
return _set_search_properties_backwards_compatible(
|
|
125
|
+
self.searcher.set_search_properties, metric, mode, config, **spec
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
def set_max_concurrency(self, max_concurrent: int) -> bool:
|
|
129
|
+
return self.searcher.set_max_concurrency(max_concurrent)
|
|
130
|
+
|
|
131
|
+
def suggest(self, trial_id: str) -> Optional[Dict]:
|
|
132
|
+
inner_id = trial_id
|
|
133
|
+
for attempt in range(1, self.MAX_ATTEMPTS + 1):
|
|
134
|
+
suggestion = self.searcher.suggest(inner_id)
|
|
135
|
+
if suggestion in (None, Searcher.FINISHED):
|
|
136
|
+
return suggestion
|
|
137
|
+
reason = invalid_combination(self.model_name, suggestion)
|
|
138
|
+
if reason is None or attempt == self.MAX_ATTEMPTS:
|
|
139
|
+
break
|
|
140
|
+
logger.attention(
|
|
141
|
+
f"Skipped the combination {suggestion} of {self.model_name}, "
|
|
142
|
+
f"which cannot be trained: {reason}"
|
|
143
|
+
)
|
|
144
|
+
self.searcher.on_trial_complete(inner_id, result=None, error=True)
|
|
145
|
+
inner_id = f"{trial_id}_retry{attempt}"
|
|
146
|
+
if inner_id != trial_id:
|
|
147
|
+
self.inner_ids[trial_id] = inner_id
|
|
148
|
+
return suggestion
|
|
149
|
+
|
|
150
|
+
def on_trial_result(self, trial_id: str, result: Dict) -> None:
|
|
151
|
+
self.searcher.on_trial_result(self._inner(trial_id), result)
|
|
152
|
+
|
|
153
|
+
def on_trial_complete(
|
|
154
|
+
self, trial_id: str, result: Optional[Dict] = None, error: bool = False
|
|
155
|
+
) -> None:
|
|
156
|
+
self.searcher.on_trial_complete(
|
|
157
|
+
self.inner_ids.pop(trial_id, trial_id), result=result, error=error
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
def add_evaluated_point(
|
|
161
|
+
self,
|
|
162
|
+
parameters: Dict,
|
|
163
|
+
value: float,
|
|
164
|
+
error: bool = False,
|
|
165
|
+
pruned: bool = False,
|
|
166
|
+
intermediate_values: Optional[List[float]] = None,
|
|
167
|
+
) -> None:
|
|
168
|
+
self.searcher.add_evaluated_point(
|
|
169
|
+
parameters, value, error, pruned, intermediate_values
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
def get_state(self) -> Dict:
|
|
173
|
+
state = self.__dict__.copy()
|
|
174
|
+
del state["searcher"]
|
|
175
|
+
return copy.deepcopy(state)
|
|
176
|
+
|
|
177
|
+
def set_state(self, state: Dict) -> None:
|
|
178
|
+
self.__dict__.update(state)
|
|
179
|
+
|
|
180
|
+
def save(self, checkpoint_path: str) -> None:
|
|
181
|
+
self.searcher.save(checkpoint_path)
|
|
182
|
+
|
|
183
|
+
def restore(self, checkpoint_path: str) -> None:
|
|
184
|
+
self.searcher.restore(checkpoint_path)
|
|
185
|
+
|
|
186
|
+
# BOHB pauses and resumes trials through its searcher
|
|
187
|
+
def on_pause(self, trial_id: str) -> None:
|
|
188
|
+
self.searcher.on_pause(self._inner(trial_id)) # type: ignore[attr-defined]
|
|
189
|
+
|
|
190
|
+
def on_unpause(self, trial_id: str) -> None:
|
|
191
|
+
self.searcher.on_unpause(self._inner(trial_id)) # type: ignore[attr-defined]
|
|
192
|
+
|
|
41
193
|
|
|
42
194
|
class ConcurrencyCap(ConcurrencyLimiter):
|
|
43
195
|
"""Ray Tune's concurrency limiter, keeping the cap it was last given.
|
|
@@ -37,7 +37,9 @@ from warprec.recommenders.trainer.logger_callbacks import (
|
|
|
37
37
|
)
|
|
38
38
|
from warprec.recommenders.trainer.objectives import TRIAL_ERROR, objective_function
|
|
39
39
|
from warprec.recommenders.trainer.search_algorithm_wrapper import (
|
|
40
|
+
CappedVariantGenerator,
|
|
40
41
|
ConcurrencyCap,
|
|
42
|
+
ValidSuggestions,
|
|
41
43
|
recap_restored_search,
|
|
42
44
|
)
|
|
43
45
|
from warprec.recommenders.trainer.timing import (
|
|
@@ -670,6 +672,13 @@ class Trainer:
|
|
|
670
672
|
max_concurrent_trials=max_concurrent_trials,
|
|
671
673
|
**opt_config.properties.model_dump(),
|
|
672
674
|
)
|
|
675
|
+
# A model whose hyperparameters constrain each other has the
|
|
676
|
+
# combinations it refuses skipped before a trial is launched for them
|
|
677
|
+
if params.need_single_trial_validation:
|
|
678
|
+
if isinstance(search_alg, CappedVariantGenerator):
|
|
679
|
+
search_alg.model_name = model_name
|
|
680
|
+
else:
|
|
681
|
+
search_alg = ValidSuggestions(search_alg, model_name)
|
|
673
682
|
# Capped by a limiter that a restored search does not reset to its old
|
|
674
683
|
# cap, so that a search resumed on another cluster runs as many trials
|
|
675
684
|
# as that cluster can hold
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{warprec-2.2.6 → warprec-2.2.8}/warprec/data/entities/train_structures/interaction_structures.py
RENAMED
|
File without changes
|
{warprec-2.2.6 → warprec-2.2.8}/warprec/data/entities/train_structures/session_structures.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|