warprec 2.0.0__tar.gz → 2.1.1__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.0.0 → warprec-2.1.1}/PKG-INFO +2 -2
- {warprec-2.0.0 → warprec-2.1.1}/README.md +1 -1
- {warprec-2.0.0 → warprec-2.1.1}/pyproject.toml +1 -1
- {warprec-2.0.0 → warprec-2.1.1}/warprec/common/initialize.py +9 -4
- {warprec-2.0.0 → warprec-2.1.1}/warprec/data/entities/knowledge.py +168 -1
- {warprec-2.0.0 → warprec-2.1.1}/warprec/data/entities/sessions.py +7 -16
- {warprec-2.0.0 → warprec-2.1.1}/warprec/data/splitting/splitter.py +19 -14
- warprec-2.1.1/warprec/recommenders/knowledge_aware_recommender/__init__.py +19 -0
- warprec-2.1.1/warprec/recommenders/knowledge_aware_recommender/kahfm.py +244 -0
- warprec-2.1.1/warprec/recommenders/knowledge_aware_recommender/kgflex.py +589 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/losses.py +6 -3
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/config/config.py +32 -4
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/config/recommender_model_config/knowledge_aware_config.py +157 -1
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/helpers.py +25 -9
- warprec-2.0.0/warprec/recommenders/knowledge_aware_recommender/__init__.py +0 -8
- {warprec-2.0.0 → warprec-2.1.1}/LICENSE +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/common/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/common/run_state.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/common/std_logs.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/data/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/data/dataset.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/data/entities/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/data/entities/common.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/data/entities/context.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/data/entities/interactions.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/data/entities/multimodal.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/data/entities/train_structures/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/data/entities/train_structures/custom_collate_fn.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/data/entities/train_structures/interaction_structures.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/data/entities/train_structures/session_structures.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/data/entities/transactions.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/data/eval_loaders.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/data/filtering.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/data/ranking.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/data/reader/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/data/reader/azureblob_reader.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/data/reader/base_reader.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/data/reader/local_reader.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/data/schema.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/data/splitting/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/data/splitting/strategies.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/data/writer/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/data/writer/azureblob_writer.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/data/writer/base_writer.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/data/writer/local_writer.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/evaluator.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/factory.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/accuracy/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/accuracy/auc.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/accuracy/f1.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/accuracy/gauc.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/accuracy/hit_rate.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/accuracy/lauc.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/accuracy/logloss.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/accuracy/map.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/accuracy/mar.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/accuracy/mrr.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/accuracy/ndcg.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/accuracy/precision.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/accuracy/recall.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/base_metric.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/bias/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/bias/aclt.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/bias/aplt.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/bias/arp.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/bias/long_tail.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/bias/pop_reo.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/bias/pop_rsp.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/coverage/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/coverage/item_coverage.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/coverage/numretrieved.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/coverage/user_coverage.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/coverage/user_coverage_at_n.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/debiased/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/debiased/base.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/debiased/dcg.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/debiased/recall.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/diversity/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/diversity/gini_index.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/diversity/shannon_entropy.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/diversity/srecall.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/fairness/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/fairness/biasdisparitybd.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/fairness/biasdisparitybr.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/fairness/biasdisparitybs.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/fairness/itemmadranking.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/fairness/itemmadrating.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/fairness/reo.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/fairness/rsp.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/fairness/usermadranking.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/fairness/usermadrating.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/multiobjective/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/multiobjective/euclideandistance.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/multiobjective/hypervolume.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/novelty/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/novelty/efd.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/novelty/epc.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/novelty/novelty_profile.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/rating/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/rating/mae.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/rating/mse.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/metrics/rating/rmse.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/propensity.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/evaluation/statistical_significance.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/pipelines/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/pipelines/common.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/pipelines/design.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/pipelines/estimate.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/pipelines/eval.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/pipelines/remotes/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/pipelines/remotes/data.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/pipelines/remotes/ml.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/pipelines/swarm.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/pipelines/train.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/base_recommender.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/callbacks.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/cdae.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/diffrec.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/ease.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/elsa.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/macridvae.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/multidae.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/multivae.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/sansa.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/dgcf.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/egcf.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/esigcf.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/gcmc.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/graph_utils.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightccf.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgcl.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgcn.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgcnpp.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgode.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/macrgcn.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/mixrec.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/ngcf.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/paac.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/popdcl.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/recdcl.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/rp3beta.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/sgcl.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/sgl.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/simgcl.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/simrec.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/ultragcn.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/xsimgcl.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/knn/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/knn/itemknn.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/knn/itemknntd.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/knn/userknn.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/knn/userknntd.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/admmslim.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/bpr.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/fism.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/ials.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/ials2008.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/macrmf.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/slim.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/neural/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/neural/convncf.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/neural/neumf.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/collaborative_filtering_recommender/neural/twotower.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/content_based_recommender/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/content_based_recommender/vsm.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/context_aware_recommender/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/context_aware_recommender/afm.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/context_aware_recommender/dcn.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/context_aware_recommender/dcnv2.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/context_aware_recommender/deepfm.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/context_aware_recommender/fm.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/context_aware_recommender/nfm.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/context_aware_recommender/wideanddeep.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/context_aware_recommender/xdeepfm.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/hybrid_recommender/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/hybrid_recommender/addease.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/hybrid_recommender/attributeitemknn.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/hybrid_recommender/attributeuserknn.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/hybrid_recommender/cease.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/knowledge_aware_recommender/cke.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/knowledge_aware_recommender/kgat.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/knowledge_aware_recommender/kgcn.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/knowledge_aware_recommender/kgin.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/knowledge_aware_recommender/knowledge_utils.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/knowledge_aware_recommender/ripplenet.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/layers.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/lr_scheduler_wrapper.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/multimodal_recommender/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/multimodal_recommender/bm3.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/multimodal_recommender/freedom.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/multimodal_recommender/lattice.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/multimodal_recommender/mgcn.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/multimodal_recommender/mmgcn.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/multimodal_recommender/multimodal_utils.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/multimodal_recommender/vbpr.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/optimizer_wrapper.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/proxy.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/reranking/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/reranking/base.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/reranking/calibration.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/reranking/factory.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/reranking/mmr.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/sequential_recommender/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/sequential_recommender/bert4rec.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/sequential_recommender/bsarec.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/sequential_recommender/caser.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/sequential_recommender/cl4srec.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/sequential_recommender/core.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/sequential_recommender/duorec.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/sequential_recommender/esasrec.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/sequential_recommender/fossil.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/sequential_recommender/gru4rec.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/sequential_recommender/gsasrec.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/sequential_recommender/lightsans.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/sequential_recommender/linrec.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/sequential_recommender/narm.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/sequential_recommender/sasrec.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/sequential_recommender/stan.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/similarities.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/trainer/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/trainer/dashboard_callbacks.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/trainer/logger_callbacks.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/trainer/objectives.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/trainer/runtime.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/trainer/scheduler_wrapper.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/trainer/search_algorithm_wrapper.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/trainer/trainer.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/unpersonalized_recommender/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/unpersonalized_recommender/pop.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/recommenders/unpersonalized_recommender/random.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/run.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/serve.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/serving/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/serving/api.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/serving/app.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/serving/catalogue.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/serving/context.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/serving/deployments.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/serving/errors.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/serving/mcp.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/serving/payload.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/serving/schemas.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/serving/servable.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/callback.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/config/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/config/common.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/config/dashboard_configuration.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/config/estimate_configuration.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/config/evaluation_configuration.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/config/general_configuration.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/config/model_configuration.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/config/reader_configuration.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/config/recommender_model_config/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/autoencoder_config.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/graph_based_config.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/knn_config.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/latent_factor_config.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/neural_config.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/config/recommender_model_config/content_based_config.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/config/recommender_model_config/context_aware_config.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/config/recommender_model_config/hybrid_config.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/config/recommender_model_config/multimodal_config.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/config/recommender_model_config/sequential_model_config.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/config/recommender_model_config/unpersonalized_config.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/config/rerank_configuration.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/config/run_configuration.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/config/search_space_wrapper.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/config/serving_configuration.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/config/splitter_configuration.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/config/training_configuration.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/config/writer_configuration.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/enums.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/logger/__init__.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/logger/logger.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/pause.py +0 -0
- {warprec-2.0.0 → warprec-2.1.1}/warprec/utils/registry.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: warprec
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.1.1
|
|
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
|
|
@@ -119,7 +119,7 @@ An **Application Layer** serves trained models on Ray Serve, as a batched REST A
|
|
|
119
119
|
|
|
120
120
|
## ✨ Key Features
|
|
121
121
|
|
|
122
|
-
- **
|
|
122
|
+
- **88 Built-in Algorithms**: WarpRec ships with 88 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.
|
|
123
123
|
- **Backend-Agnostic Data Engine**: Built on [Narwhals](https://narwhals-dev.github.io/narwhals/), WarpRec operates over Pandas, Polars, and Spark 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).
|
|
124
124
|
- **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.
|
|
125
125
|
- **45 GPU-Accelerated Metrics**: The evaluation suite covers 45 metrics across 8 families — Accuracy, Rating, Coverage, Novelty, Diversity, Bias, Fairness, and Debiased — including multi-objective metrics for 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.
|
|
@@ -59,7 +59,7 @@ An **Application Layer** serves trained models on Ray Serve, as a batched REST A
|
|
|
59
59
|
|
|
60
60
|
## ✨ Key Features
|
|
61
61
|
|
|
62
|
-
- **
|
|
62
|
+
- **88 Built-in Algorithms**: WarpRec ships with 88 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.
|
|
63
63
|
- **Backend-Agnostic Data Engine**: Built on [Narwhals](https://narwhals-dev.github.io/narwhals/), WarpRec operates over Pandas, Polars, and Spark 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).
|
|
64
64
|
- **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.
|
|
65
65
|
- **45 GPU-Accelerated Metrics**: The evaluation suite covers 45 metrics across 8 families — Accuracy, Rating, Coverage, Novelty, Diversity, Bias, Fairness, and Debiased — including multi-objective metrics for 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.
|
|
@@ -234,10 +234,15 @@ def initialize_datasets(
|
|
|
234
234
|
test_data = _align_set_on_train(train_data, test_data, "Test")
|
|
235
235
|
if val_data is not None:
|
|
236
236
|
if isinstance(val_data, list):
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
237
|
+
# A fold is trained on its own train set, so that is the
|
|
238
|
+
# one its validation set has to be aligned with.
|
|
239
|
+
val_data = [
|
|
240
|
+
(
|
|
241
|
+
val_train,
|
|
242
|
+
_align_set_on_train(val_train, val_set, "Validation"),
|
|
240
243
|
)
|
|
244
|
+
for val_train, val_set in val_data
|
|
245
|
+
]
|
|
241
246
|
else:
|
|
242
247
|
val_data = _align_set_on_train(train_data, val_data, "Validation")
|
|
243
248
|
else:
|
|
@@ -337,7 +342,7 @@ def initialize_datasets(
|
|
|
337
342
|
specific_config["id_type"],
|
|
338
343
|
common_cluster_type,
|
|
339
344
|
]
|
|
340
|
-
dtype_map = zip(column_names, dtypes_list)
|
|
345
|
+
dtype_map = dict(zip(column_names, dtypes_list))
|
|
341
346
|
|
|
342
347
|
# Read data using the custom reader
|
|
343
348
|
file_format = specific_config["file_format"]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Any, Dict, Optional, Tuple
|
|
1
|
+
from typing import Any, Dict, List, Optional, Tuple
|
|
2
2
|
|
|
3
3
|
import numpy as np
|
|
4
4
|
import torch
|
|
@@ -61,6 +61,8 @@ class KnowledgeGraph:
|
|
|
61
61
|
relations = sorted(set(raw_relations.tolist()))
|
|
62
62
|
self._entity_index = {entity: i for i, entity in enumerate(entities)}
|
|
63
63
|
self._relation_index = {relation: i for i, relation in enumerate(relations)}
|
|
64
|
+
self._entity_names = entities
|
|
65
|
+
self._relation_names = relations
|
|
64
66
|
|
|
65
67
|
self.n_entities = len(self._entity_index)
|
|
66
68
|
self.n_relations = len(self._relation_index)
|
|
@@ -71,6 +73,10 @@ class KnowledgeGraph:
|
|
|
71
73
|
|
|
72
74
|
self._item_entity = self._align(links, item_mapping, item_label, entity_label)
|
|
73
75
|
self._neighbour_index: Optional[Tuple[Tensor, Tensor, Tensor]] = None
|
|
76
|
+
self._outgoing_index: Optional[Tuple[Tensor, Tensor]] = None
|
|
77
|
+
self._item_features: Dict[
|
|
78
|
+
Tuple[int, int], Tuple[Tensor, List[Tuple[Any, ...]]]
|
|
79
|
+
] = {}
|
|
74
80
|
|
|
75
81
|
aligned = int((self._item_entity >= 0).sum())
|
|
76
82
|
logger.stat_msg(
|
|
@@ -245,6 +251,167 @@ class KnowledgeGraph:
|
|
|
245
251
|
|
|
246
252
|
return sampled_entities, sampled_relations
|
|
247
253
|
|
|
254
|
+
def _outgoing(self) -> Tuple[Tensor, Tensor]:
|
|
255
|
+
"""The facts leaving each entity, in the direction they were written.
|
|
256
|
+
|
|
257
|
+
``neighbour_index`` reads a fact from both ends, which is what a model
|
|
258
|
+
propagating over the graph wants. A feature is a statement about an
|
|
259
|
+
item, so it is read only from the end the fact was written about.
|
|
260
|
+
|
|
261
|
+
Returns:
|
|
262
|
+
Tuple[Tensor, Tensor]: The offsets, and the facts ordered by head:
|
|
263
|
+
the facts leaving entity ``e`` are
|
|
264
|
+
``facts[offsets[e]:offsets[e + 1]]``.
|
|
265
|
+
"""
|
|
266
|
+
if self._outgoing_index is None:
|
|
267
|
+
facts = torch.argsort(self._heads, stable=True)
|
|
268
|
+
counts = torch.bincount(self._heads, minlength=self.n_entities)
|
|
269
|
+
|
|
270
|
+
offsets = torch.zeros(self.n_entities + 1, dtype=torch.long)
|
|
271
|
+
offsets[1:] = torch.cumsum(counts, dim=0)
|
|
272
|
+
|
|
273
|
+
self._outgoing_index = (offsets, facts)
|
|
274
|
+
|
|
275
|
+
return self._outgoing_index
|
|
276
|
+
|
|
277
|
+
def _follow(self, owners: Tensor, entities: Tensor) -> Tuple[Tensor, Tensor]:
|
|
278
|
+
"""Follow every fact leaving the given entities.
|
|
279
|
+
|
|
280
|
+
Args:
|
|
281
|
+
owners (Tensor): Whom each entity is followed on behalf of.
|
|
282
|
+
entities (Tensor): The entity to leave from, one per owner.
|
|
283
|
+
|
|
284
|
+
Returns:
|
|
285
|
+
Tuple[Tensor, Tensor]: The owner of each fact reached, and the fact.
|
|
286
|
+
"""
|
|
287
|
+
offsets, facts = self._outgoing()
|
|
288
|
+
start = offsets[entities]
|
|
289
|
+
degree = offsets[entities + 1] - start
|
|
290
|
+
|
|
291
|
+
# Each owner reaches a run of consecutive facts; the step counts along
|
|
292
|
+
# that run and restarts at zero for every owner.
|
|
293
|
+
run_start = torch.cumsum(degree, dim=0) - degree
|
|
294
|
+
step = torch.arange(int(degree.sum())) - torch.repeat_interleave(
|
|
295
|
+
run_start, degree
|
|
296
|
+
)
|
|
297
|
+
|
|
298
|
+
reached = facts[torch.repeat_interleave(start, degree) + step]
|
|
299
|
+
return torch.repeat_interleave(owners, degree), reached
|
|
300
|
+
|
|
301
|
+
def item_features(
|
|
302
|
+
self, order: int, min_items: int = 1
|
|
303
|
+
) -> Tuple[Tensor, List[Tuple[Any, ...]]]:
|
|
304
|
+
"""The facts about each item, flattened into binary features.
|
|
305
|
+
|
|
306
|
+
A first-order feature is a ``(relation, tail)`` pair leaving the item's
|
|
307
|
+
entity: *directed by Kubrick*. A second-order feature walks one fact
|
|
308
|
+
further, ``(relation, relation, tail)``: *directed by someone born in
|
|
309
|
+
the UK*. This is how the feature-based models read a graph: as an
|
|
310
|
+
attribute table built from it, not as a structure to propagate over.
|
|
311
|
+
|
|
312
|
+
A feature only a handful of items carry says little and costs a column,
|
|
313
|
+
so it is kept only when at least ``min_items`` items of the catalogue
|
|
314
|
+
carry it. The table is built once per request and kept, because every
|
|
315
|
+
trial builds a model and every model asks for the same one.
|
|
316
|
+
|
|
317
|
+
Args:
|
|
318
|
+
order (int): 1 for first-order features, 2 for second-order ones.
|
|
319
|
+
min_items (int): How many items must carry a feature for it to be kept.
|
|
320
|
+
|
|
321
|
+
Returns:
|
|
322
|
+
Tuple[Tensor, List[Tuple[Any, ...]]]: The sparse binary
|
|
323
|
+
{item x feature} matrix, and each column's feature written with
|
|
324
|
+
the identifiers the graph was read with.
|
|
325
|
+
|
|
326
|
+
Raises:
|
|
327
|
+
ValueError: If the order is not 1 or 2, or min_items is below 1.
|
|
328
|
+
"""
|
|
329
|
+
if order not in (1, 2):
|
|
330
|
+
raise ValueError(f"An item feature is one or two facts long, not {order}.")
|
|
331
|
+
if min_items < 1:
|
|
332
|
+
raise ValueError(f"min_items must be at least 1, received {min_items}.")
|
|
333
|
+
|
|
334
|
+
key = (order, min_items)
|
|
335
|
+
if key not in self._item_features:
|
|
336
|
+
self._item_features[key] = self._build_item_features(order, min_items)
|
|
337
|
+
|
|
338
|
+
return self._item_features[key]
|
|
339
|
+
|
|
340
|
+
def _build_item_features(
|
|
341
|
+
self, order: int, min_items: int
|
|
342
|
+
) -> Tuple[Tensor, List[Tuple[Any, ...]]]:
|
|
343
|
+
"""Walk the graph from every item and count what it reaches.
|
|
344
|
+
|
|
345
|
+
Args:
|
|
346
|
+
order (int): 1 for first-order features, 2 for second-order ones.
|
|
347
|
+
min_items (int): How many items must carry a feature for it to be kept.
|
|
348
|
+
|
|
349
|
+
Returns:
|
|
350
|
+
Tuple[Tensor, List[Tuple[Any, ...]]]: The matrix and the labels.
|
|
351
|
+
"""
|
|
352
|
+
n_items = len(self._item_entity)
|
|
353
|
+
items = torch.nonzero(self._item_entity >= 0).flatten()
|
|
354
|
+
|
|
355
|
+
owners, facts = self._follow(items, self._item_entity[items])
|
|
356
|
+
relations, tails = self._relations[facts], self._tails[facts]
|
|
357
|
+
|
|
358
|
+
# A feature is encoded as one integer, so that it can be deduplicated
|
|
359
|
+
# and counted with tensor operations rather than a dictionary.
|
|
360
|
+
if order == 1:
|
|
361
|
+
codes = relations * self.n_entities + tails
|
|
362
|
+
else:
|
|
363
|
+
path, further = self._follow(torch.arange(len(owners)), tails)
|
|
364
|
+
owners = owners[path]
|
|
365
|
+
codes = (
|
|
366
|
+
relations[path] * self.n_relations + self._relations[further]
|
|
367
|
+
) * self.n_entities + self._tails[further]
|
|
368
|
+
|
|
369
|
+
if owners.numel() == 0:
|
|
370
|
+
empty = torch.sparse_coo_tensor(
|
|
371
|
+
torch.zeros((2, 0), dtype=torch.long), torch.zeros(0), (n_items, 0)
|
|
372
|
+
)
|
|
373
|
+
return empty.coalesce(), []
|
|
374
|
+
|
|
375
|
+
# An item reaching the same feature along two paths carries it once.
|
|
376
|
+
owners, codes = torch.unique(torch.stack([owners, codes]), dim=1)
|
|
377
|
+
vocabulary, column, support = torch.unique(
|
|
378
|
+
codes, return_inverse=True, return_counts=True
|
|
379
|
+
)
|
|
380
|
+
|
|
381
|
+
kept = support >= min_items
|
|
382
|
+
renumbered = torch.cumsum(kept.long(), dim=0) - 1
|
|
383
|
+
carried = kept[column]
|
|
384
|
+
|
|
385
|
+
matrix = torch.sparse_coo_tensor(
|
|
386
|
+
torch.stack([owners[carried], renumbered[column[carried]]]),
|
|
387
|
+
torch.ones(int(carried.sum())),
|
|
388
|
+
(n_items, int(kept.sum())),
|
|
389
|
+
).coalesce()
|
|
390
|
+
labels = [self._describe(code, order) for code in vocabulary[kept].tolist()]
|
|
391
|
+
|
|
392
|
+
return matrix, labels
|
|
393
|
+
|
|
394
|
+
def _describe(self, code: int, order: int) -> Tuple[Any, ...]:
|
|
395
|
+
"""Write an encoded feature back with the graph's own identifiers.
|
|
396
|
+
|
|
397
|
+
Args:
|
|
398
|
+
code (int): The feature, as encoded while it was counted.
|
|
399
|
+
order (int): How many facts long the feature is.
|
|
400
|
+
|
|
401
|
+
Returns:
|
|
402
|
+
Tuple[Any, ...]: The relations and the tail the feature names.
|
|
403
|
+
"""
|
|
404
|
+
rest, tail = divmod(code, self.n_entities)
|
|
405
|
+
if order == 1:
|
|
406
|
+
return (self._relation_names[rest], self._entity_names[tail])
|
|
407
|
+
|
|
408
|
+
first, second = divmod(rest, self.n_relations)
|
|
409
|
+
return (
|
|
410
|
+
self._relation_names[first],
|
|
411
|
+
self._relation_names[second],
|
|
412
|
+
self._entity_names[tail],
|
|
413
|
+
)
|
|
414
|
+
|
|
248
415
|
def adjacency(
|
|
249
416
|
self,
|
|
250
417
|
values: Optional[Tensor] = None,
|
|
@@ -129,23 +129,14 @@ class Sessions:
|
|
|
129
129
|
self._flat_users = df.select(self.user_label).to_numpy().flatten()
|
|
130
130
|
self._flat_items = df.select(self.item_label).to_numpy().flatten()
|
|
131
131
|
|
|
132
|
-
# Calculate Offsets
|
|
133
|
-
#
|
|
134
|
-
|
|
135
|
-
|
|
132
|
+
# Calculate Offsets. The tape is sorted by user, so a user's rows start
|
|
133
|
+
# where the counts of every lower index end. Counting rather than
|
|
134
|
+
# locating starts gives a user with no rows an empty range wherever it
|
|
135
|
+
# falls, the end of the index space included, which a cold-start
|
|
136
|
+
# protocol produces whenever it holds out the highest indices.
|
|
137
|
+
counts = np.bincount(self._flat_users, minlength=self._nuid)
|
|
136
138
|
self._user_offsets = np.zeros(self._nuid + 1, dtype=np.int64)
|
|
137
|
-
|
|
138
|
-
# Set starts
|
|
139
|
-
self._user_offsets[unique_users] = start_indices
|
|
140
|
-
# Set ends (start of next user)
|
|
141
|
-
self._user_offsets[unique_users + 1] = np.roll(start_indices, -1)
|
|
142
|
-
self._user_offsets[-1] = len(self._flat_items)
|
|
143
|
-
|
|
144
|
-
# Fill gaps for users with no interactions (propagate previous offset)
|
|
145
|
-
# This ensures user_offsets[u] == user_offsets[u+1] for empty users
|
|
146
|
-
for i in range(1, len(self._user_offsets)):
|
|
147
|
-
if self._user_offsets[i] == 0 and self._user_offsets[i - 1] > 0:
|
|
148
|
-
self._user_offsets[i] = self._user_offsets[i - 1]
|
|
139
|
+
np.cumsum(counts, out=self._user_offsets[1:])
|
|
149
140
|
|
|
150
141
|
def get_user_history_sequences(
|
|
151
142
|
self, user_ids: List[int], max_seq_len: int
|
|
@@ -99,31 +99,36 @@ class Splitter:
|
|
|
99
99
|
# CASE 1: Only train and test set
|
|
100
100
|
return (original_train_set, None, test_set)
|
|
101
101
|
|
|
102
|
+
# Each validation set is aligned with the train set it validates.
|
|
103
|
+
validation_folds = [
|
|
104
|
+
(
|
|
105
|
+
train,
|
|
106
|
+
self.filter_sets(
|
|
107
|
+
train,
|
|
108
|
+
val_set,
|
|
109
|
+
labels.user_id,
|
|
110
|
+
labels.item_id,
|
|
111
|
+
"Validation",
|
|
112
|
+
cold_dimension=cold,
|
|
113
|
+
),
|
|
114
|
+
)
|
|
115
|
+
for train, val_set in validation_folds
|
|
116
|
+
]
|
|
117
|
+
|
|
102
118
|
if len(validation_folds) == 1:
|
|
103
|
-
# CASE 2: Train/Validation/Test
|
|
119
|
+
# CASE 2: Train/Validation/Test. The main model trains on the train
|
|
120
|
+
# set the validation split left, so the test set is aligned with it.
|
|
104
121
|
train_set, validation_set = validation_folds[0]
|
|
105
122
|
test_set = self.filter_sets(
|
|
106
123
|
train_set,
|
|
107
124
|
test_set,
|
|
108
125
|
labels.user_id,
|
|
109
126
|
labels.item_id,
|
|
110
|
-
"
|
|
127
|
+
"Test",
|
|
111
128
|
cold_dimension=cold,
|
|
112
129
|
)
|
|
113
130
|
return (train_set, validation_set, test_set)
|
|
114
131
|
|
|
115
|
-
# Filter out each validation set based on
|
|
116
|
-
# corresponding train set
|
|
117
|
-
for train, val_set in validation_folds:
|
|
118
|
-
val_set = self.filter_sets(
|
|
119
|
-
train,
|
|
120
|
-
val_set,
|
|
121
|
-
labels.user_id,
|
|
122
|
-
labels.item_id,
|
|
123
|
-
"Validation",
|
|
124
|
-
cold_dimension=cold,
|
|
125
|
-
)
|
|
126
|
-
|
|
127
132
|
# CASE 3: N folds of train and validation + the test set
|
|
128
133
|
return (original_train_set, validation_folds, test_set)
|
|
129
134
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from .cke import CKE
|
|
2
|
+
from .kahfm import KaHFM
|
|
3
|
+
from .kgat import KGAT
|
|
4
|
+
from .kgcn import KGCN
|
|
5
|
+
from .kgflex import KGFlex
|
|
6
|
+
from .kgin import KGIN
|
|
7
|
+
from .knowledge_utils import KnowledgeRecommenderUtils
|
|
8
|
+
from .ripplenet import RippleNet
|
|
9
|
+
|
|
10
|
+
__all__ = [
|
|
11
|
+
"CKE",
|
|
12
|
+
"KaHFM",
|
|
13
|
+
"KGAT",
|
|
14
|
+
"KGCN",
|
|
15
|
+
"KGFlex",
|
|
16
|
+
"KGIN",
|
|
17
|
+
"KnowledgeRecommenderUtils",
|
|
18
|
+
"RippleNet",
|
|
19
|
+
]
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
# pylint: disable = R0801, E1102
|
|
2
|
+
from typing import Any, List, Optional, Tuple
|
|
3
|
+
|
|
4
|
+
import numpy as np
|
|
5
|
+
import torch
|
|
6
|
+
from torch import Tensor, nn
|
|
7
|
+
|
|
8
|
+
from warprec.data.entities import Interactions, KnowledgeGraph, Sessions
|
|
9
|
+
from warprec.recommenders.base_recommender import IterativeRecommender
|
|
10
|
+
from warprec.recommenders.knowledge_aware_recommender.knowledge_utils import (
|
|
11
|
+
KnowledgeRecommenderUtils,
|
|
12
|
+
)
|
|
13
|
+
from warprec.recommenders.losses import BPRLoss, EmbLoss
|
|
14
|
+
from warprec.utils.enums import DataLoaderType
|
|
15
|
+
from warprec.utils.registry import model_registry
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@model_registry.register(name="KaHFM")
|
|
19
|
+
class KaHFM(KnowledgeRecommenderUtils, IterativeRecommender):
|
|
20
|
+
"""Implementation of KaHFM algorithm from
|
|
21
|
+
How to Make Latent Factors Interpretable by Feeding Factorization
|
|
22
|
+
Machines with Knowledge Graphs (ISWC 2019), extended in Semantic
|
|
23
|
+
Interpretation of Top-N Recommendations (TKDE 2020)
|
|
24
|
+
|
|
25
|
+
A factorization model whose factors are not latent: there is one per
|
|
26
|
+
feature the graph states about the items, so a user's factor is how much
|
|
27
|
+
they care about *directed by Kubrick* and an item's is how much it is about
|
|
28
|
+
it. The factors start from what is already known, an item at the TF-IDF of
|
|
29
|
+
its features and a user at the mean of the items they interacted with, and
|
|
30
|
+
BPR refines them from there, which keeps every factor tied to the feature
|
|
31
|
+
it started from.
|
|
32
|
+
|
|
33
|
+
The original implementation is in Elliot as KaHFM, KaHFMBatch and
|
|
34
|
+
KaHFMEmbeddings, which differ in how they are optimised; this one trains in
|
|
35
|
+
mini-batches through the configured optimizer. Elliot keeps, for each
|
|
36
|
+
feature of a user's profile, only the value of the last item carrying it;
|
|
37
|
+
the profile here is the mean the paper defines.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
params (dict): Model parameters.
|
|
41
|
+
info (dict): The dictionary containing dataset information.
|
|
42
|
+
interactions (Interactions): The training interactions.
|
|
43
|
+
*args (Any): Variable length argument list.
|
|
44
|
+
knowledge (Optional[KnowledgeGraph]): The facts about the items.
|
|
45
|
+
seed (int): The seed to use for reproducibility.
|
|
46
|
+
**kwargs (Any): Arbitrary keyword arguments.
|
|
47
|
+
|
|
48
|
+
Attributes:
|
|
49
|
+
DATALOADER_TYPE: The type of dataloader used.
|
|
50
|
+
min_feature_items (int): How many items must carry a feature for it to
|
|
51
|
+
become a factor.
|
|
52
|
+
reg_weight (float): The L2 regularization weight of the factors.
|
|
53
|
+
bias_reg_weight (float): The L2 regularization weight of the item biases.
|
|
54
|
+
batch_size (int): The batch size used for training.
|
|
55
|
+
epochs (int): The number of epochs.
|
|
56
|
+
learning_rate (float): The learning rate value.
|
|
57
|
+
|
|
58
|
+
Raises:
|
|
59
|
+
ValueError: If the interactions were not provided, or no feature is
|
|
60
|
+
carried by at least min_feature_items items.
|
|
61
|
+
"""
|
|
62
|
+
|
|
63
|
+
DATALOADER_TYPE = DataLoaderType.POS_NEG_LOADER
|
|
64
|
+
|
|
65
|
+
min_feature_items: int
|
|
66
|
+
reg_weight: float
|
|
67
|
+
bias_reg_weight: float
|
|
68
|
+
batch_size: int
|
|
69
|
+
epochs: int
|
|
70
|
+
learning_rate: float
|
|
71
|
+
|
|
72
|
+
def __init__(
|
|
73
|
+
self,
|
|
74
|
+
params: dict,
|
|
75
|
+
info: dict,
|
|
76
|
+
interactions: Interactions,
|
|
77
|
+
*args: Any,
|
|
78
|
+
knowledge: Optional[KnowledgeGraph] = None,
|
|
79
|
+
seed: int = 42,
|
|
80
|
+
**kwargs: Any,
|
|
81
|
+
):
|
|
82
|
+
# pylint: disable = too-many-arguments, too-many-positional-arguments
|
|
83
|
+
super().__init__(params, info, *args, knowledge=knowledge, seed=seed, **kwargs)
|
|
84
|
+
|
|
85
|
+
if interactions is None:
|
|
86
|
+
raise ValueError(
|
|
87
|
+
"KaHFM starts every user from the items they interacted with, so "
|
|
88
|
+
"it needs the interactions at construction."
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
features, labels = self._graph.item_features(
|
|
92
|
+
order=1, min_items=self.min_feature_items
|
|
93
|
+
)
|
|
94
|
+
# Annotated here rather than on the class: class annotations are read
|
|
95
|
+
# as hyperparameters, and a run is named after them.
|
|
96
|
+
self.feature_labels: List[Tuple[Any, ...]] = labels
|
|
97
|
+
if features.size(1) == 0:
|
|
98
|
+
raise ValueError(
|
|
99
|
+
f"No feature of the knowledge graph is carried by "
|
|
100
|
+
f"{self.min_feature_items} items or more, so KaHFM has no factor "
|
|
101
|
+
"to learn. Lower min_feature_items."
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
item_factors = self.tfidf(features)
|
|
105
|
+
user_factors = self.profiles(interactions, item_factors)
|
|
106
|
+
|
|
107
|
+
# The row past the catalogue is the item a sampled candidate list is
|
|
108
|
+
# padded with, and it stays at zero.
|
|
109
|
+
padding = torch.zeros(1, item_factors.size(1))
|
|
110
|
+
self.user_factors = nn.Embedding.from_pretrained(user_factors, freeze=False)
|
|
111
|
+
self.item_factors = nn.Embedding.from_pretrained(
|
|
112
|
+
torch.cat([item_factors, padding]), freeze=False, padding_idx=self.n_items
|
|
113
|
+
)
|
|
114
|
+
self.item_bias = nn.Embedding(self.n_items + 1, 1, padding_idx=self.n_items)
|
|
115
|
+
nn.init.zeros_(self.item_bias.weight)
|
|
116
|
+
|
|
117
|
+
self.rec_loss = BPRLoss()
|
|
118
|
+
self.reg_loss = EmbLoss()
|
|
119
|
+
|
|
120
|
+
@staticmethod
|
|
121
|
+
def tfidf(features: Tensor) -> Tensor:
|
|
122
|
+
"""The TF-IDF of every item over its features, at unit length.
|
|
123
|
+
|
|
124
|
+
A feature is either carried or not, so its term frequency is one and
|
|
125
|
+
its weight is the inverse document frequency ``ln(N / df)``, where N is
|
|
126
|
+
the number of items that carry any feature. An item with no feature,
|
|
127
|
+
or only features every item carries, is left at zero.
|
|
128
|
+
|
|
129
|
+
Args:
|
|
130
|
+
features (Tensor): The sparse binary {item x feature} matrix.
|
|
131
|
+
|
|
132
|
+
Returns:
|
|
133
|
+
Tensor: The dense {item x feature} TF-IDF matrix, one unit row per item.
|
|
134
|
+
"""
|
|
135
|
+
rows, columns = features.coalesce().indices()
|
|
136
|
+
n_items, n_features = features.shape
|
|
137
|
+
|
|
138
|
+
frequency = torch.bincount(columns, minlength=n_features).float()
|
|
139
|
+
described = torch.unique(rows).numel()
|
|
140
|
+
values = torch.log(described / frequency.clamp(min=1))[columns]
|
|
141
|
+
|
|
142
|
+
norm = torch.zeros(n_items).index_add_(0, rows, values**2).sqrt()
|
|
143
|
+
values = values / norm[rows].clamp(min=torch.finfo(values.dtype).tiny)
|
|
144
|
+
|
|
145
|
+
dense = torch.zeros(n_items, n_features)
|
|
146
|
+
dense[rows, columns] = values
|
|
147
|
+
return dense
|
|
148
|
+
|
|
149
|
+
def profiles(self, interactions: Interactions, item_factors: Tensor) -> Tensor:
|
|
150
|
+
"""Where every user starts: the mean of the items they interacted with.
|
|
151
|
+
|
|
152
|
+
The mean is taken over the whole history, items the graph says nothing
|
|
153
|
+
about included, as the paper defines the profile.
|
|
154
|
+
|
|
155
|
+
Args:
|
|
156
|
+
interactions (Interactions): The training interactions.
|
|
157
|
+
item_factors (Tensor): The {item x feature} starting factors.
|
|
158
|
+
|
|
159
|
+
Returns:
|
|
160
|
+
Tensor: The {user x feature} starting factors.
|
|
161
|
+
"""
|
|
162
|
+
history = interactions.get_sparse().tocsr().astype(np.float32)
|
|
163
|
+
history.data[:] = 1.0
|
|
164
|
+
|
|
165
|
+
taken = np.maximum(np.diff(history.indptr), 1)
|
|
166
|
+
summed = history @ item_factors.numpy()
|
|
167
|
+
return torch.from_numpy(summed / taken[:, None]).float()
|
|
168
|
+
|
|
169
|
+
def get_dataloader(
|
|
170
|
+
self,
|
|
171
|
+
interactions: Interactions,
|
|
172
|
+
sessions: Sessions,
|
|
173
|
+
**kwargs: Any,
|
|
174
|
+
):
|
|
175
|
+
return interactions.get_contrastive_dataloader(
|
|
176
|
+
batch_size=self.batch_size,
|
|
177
|
+
**kwargs,
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
def training_step(self, batch: Any, batch_idx: int) -> Tensor:
|
|
181
|
+
user, positive, negative = batch
|
|
182
|
+
|
|
183
|
+
user_f = self.user_factors(user)
|
|
184
|
+
positive_f = self.item_factors(positive)
|
|
185
|
+
negative_f = self.item_factors(negative)
|
|
186
|
+
positive_b = self.item_bias(positive).squeeze(-1)
|
|
187
|
+
negative_b = self.item_bias(negative).squeeze(-1)
|
|
188
|
+
|
|
189
|
+
positive_score = positive_b + (user_f * positive_f).sum(dim=-1)
|
|
190
|
+
negative_score = negative_b + (user_f * negative_f).sum(dim=-1)
|
|
191
|
+
|
|
192
|
+
loss = (
|
|
193
|
+
self.rec_loss(positive_score, negative_score)
|
|
194
|
+
+ self.reg_weight * self.reg_loss(user_f, positive_f, negative_f)
|
|
195
|
+
+ self.bias_reg_weight * self.reg_loss(positive_b, negative_b)
|
|
196
|
+
)
|
|
197
|
+
|
|
198
|
+
self.log("loss", loss, prog_bar=True, on_step=False, on_epoch=True)
|
|
199
|
+
return loss
|
|
200
|
+
|
|
201
|
+
def forward(self, user: Tensor, item: Tensor) -> Tensor:
|
|
202
|
+
"""Score each given user against the item beside it.
|
|
203
|
+
|
|
204
|
+
Args:
|
|
205
|
+
user (Tensor): The user indices.
|
|
206
|
+
item (Tensor): The item indices.
|
|
207
|
+
|
|
208
|
+
Returns:
|
|
209
|
+
Tensor: One score per pair.
|
|
210
|
+
"""
|
|
211
|
+
return self.item_bias(item).squeeze(-1) + (
|
|
212
|
+
self.user_factors(user) * self.item_factors(item)
|
|
213
|
+
).sum(dim=-1)
|
|
214
|
+
|
|
215
|
+
def predict(
|
|
216
|
+
self,
|
|
217
|
+
user_indices: Tensor,
|
|
218
|
+
*args: Any,
|
|
219
|
+
item_indices: Optional[Tensor] = None,
|
|
220
|
+
**kwargs: Any,
|
|
221
|
+
) -> Tensor:
|
|
222
|
+
"""Prediction from the feature factors and the item biases.
|
|
223
|
+
|
|
224
|
+
Args:
|
|
225
|
+
user_indices (Tensor): The batch of user indices.
|
|
226
|
+
*args (Any): List of arguments.
|
|
227
|
+
item_indices (Optional[Tensor]): The batch of item indices. If None,
|
|
228
|
+
full prediction will be produced.
|
|
229
|
+
**kwargs (Any): The dictionary of keyword arguments.
|
|
230
|
+
|
|
231
|
+
Returns:
|
|
232
|
+
Tensor: The score matrix {user x item}.
|
|
233
|
+
"""
|
|
234
|
+
user_f = self.user_factors(user_indices)
|
|
235
|
+
|
|
236
|
+
if item_indices is None:
|
|
237
|
+
return (
|
|
238
|
+
user_f @ self.item_factors.weight[:-1].t()
|
|
239
|
+
+ self.item_bias.weight[:-1].t()
|
|
240
|
+
)
|
|
241
|
+
|
|
242
|
+
return torch.einsum(
|
|
243
|
+
"bf,bsf->bs", user_f, self.item_factors(item_indices)
|
|
244
|
+
) + self.item_bias(item_indices).squeeze(-1)
|