warprec 2.2.0__tar.gz → 2.2.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.2.0 → warprec-2.2.1}/PKG-INFO +1 -1
- {warprec-2.2.0 → warprec-2.2.1}/pyproject.toml +1 -1
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/evaluator.py +73 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/accuracy/f1.py +19 -3
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/base_metric.py +70 -4
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/bias/long_tail.py +2 -2
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/bias/pop_reo.py +2 -2
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/bias/pop_rsp.py +2 -2
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/multiobjective/euclideandistance.py +13 -1
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/multiobjective/hypervolume.py +13 -1
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/novelty/novelty_profile.py +2 -2
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/trainer/dashboard_callbacks.py +31 -1
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/config/common.py +175 -1
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/config/config.py +52 -1
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/registry.py +21 -0
- {warprec-2.2.0 → warprec-2.2.1}/LICENSE +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/README.md +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/common/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/common/initialize.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/common/run_state.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/common/std_logs.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/data/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/data/dataset.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/data/entities/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/data/entities/common.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/data/entities/context.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/data/entities/interactions.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/data/entities/knowledge.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/data/entities/multimodal.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/data/entities/sessions.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/data/entities/train_structures/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/data/entities/train_structures/custom_collate_fn.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/data/entities/train_structures/interaction_structures.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/data/entities/train_structures/session_structures.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/data/entities/transactions.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/data/eval_loaders.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/data/filtering.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/data/ranking.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/data/reader/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/data/reader/azureblob_reader.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/data/reader/base_reader.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/data/reader/local_reader.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/data/schema.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/data/splitting/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/data/splitting/splitter.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/data/splitting/strategies.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/data/stash.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/data/writer/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/data/writer/azureblob_writer.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/data/writer/base_writer.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/data/writer/local_writer.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/errors.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/factory.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/accuracy/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/accuracy/auc.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/accuracy/gauc.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/accuracy/hit_rate.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/accuracy/lauc.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/accuracy/logloss.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/accuracy/map.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/accuracy/mar.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/accuracy/mrr.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/accuracy/ndcg.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/accuracy/precision.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/accuracy/recall.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/bias/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/bias/aclt.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/bias/aplt.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/bias/arp.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/coverage/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/coverage/item_coverage.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/coverage/numretrieved.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/coverage/user_coverage.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/coverage/user_coverage_at_n.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/debiased/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/debiased/base.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/debiased/dcg.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/debiased/recall.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/diversity/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/diversity/gini_index.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/diversity/shannon_entropy.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/diversity/srecall.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/fairness/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/fairness/biasdisparitybd.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/fairness/biasdisparitybr.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/fairness/biasdisparitybs.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/fairness/itemmadranking.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/fairness/itemmadrating.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/fairness/reo.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/fairness/rsp.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/fairness/usermadranking.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/fairness/usermadrating.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/multiobjective/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/novelty/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/novelty/efd.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/novelty/epc.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/rating/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/rating/mae.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/rating/mse.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/rating/rmse.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/propensity.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/statistical_significance.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/pipelines/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/pipelines/common.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/pipelines/design.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/pipelines/estimate.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/pipelines/eval.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/pipelines/remotes/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/pipelines/remotes/data.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/pipelines/remotes/ml.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/pipelines/swarm.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/pipelines/train.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/base_recommender.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/callbacks.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/cdae.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/diffrec.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/ease.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/elsa.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/macridvae.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/multidae.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/multivae.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/sansa.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/dgcf.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/egcf.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/esigcf.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/gcmc.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/graph_utils.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightccf.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgcl.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgcn.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgcnpp.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgode.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/macrgcn.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/mixrec.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/ngcf.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/paac.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/popdcl.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/recdcl.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/rp3beta.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/sgcl.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/sgl.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/simgcl.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/simrec.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/ultragcn.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/graph_based/xsimgcl.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/knn/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/knn/itemknn.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/knn/itemknntd.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/knn/userknn.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/knn/userknntd.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/admmslim.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/bpr.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/fism.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/ials.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/ials2008.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/macrmf.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/slim.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/neural/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/neural/convncf.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/neural/neumf.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/collaborative_filtering_recommender/neural/twotower.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/content_based_recommender/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/content_based_recommender/vsm.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/context_aware_recommender/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/context_aware_recommender/afm.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/context_aware_recommender/dcn.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/context_aware_recommender/dcnv2.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/context_aware_recommender/deepfm.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/context_aware_recommender/fm.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/context_aware_recommender/nfm.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/context_aware_recommender/wideanddeep.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/context_aware_recommender/xdeepfm.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/hybrid_recommender/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/hybrid_recommender/addease.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/hybrid_recommender/attributeitemknn.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/hybrid_recommender/attributeuserknn.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/hybrid_recommender/cease.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/knowledge_aware_recommender/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/knowledge_aware_recommender/cke.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/knowledge_aware_recommender/kahfm.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/knowledge_aware_recommender/kgat.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/knowledge_aware_recommender/kgcn.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/knowledge_aware_recommender/kgflex.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/knowledge_aware_recommender/kgin.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/knowledge_aware_recommender/knowledge_utils.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/knowledge_aware_recommender/ripplenet.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/layers.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/losses.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/lr_scheduler_wrapper.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/multimodal_recommender/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/multimodal_recommender/bm3.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/multimodal_recommender/freedom.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/multimodal_recommender/lattice.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/multimodal_recommender/mgcn.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/multimodal_recommender/mmgcn.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/multimodal_recommender/multimodal_utils.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/multimodal_recommender/vbpr.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/optimizer_wrapper.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/proxy.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/reranking/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/reranking/base.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/reranking/calibration.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/reranking/factory.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/reranking/mmr.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/sequential_recommender/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/sequential_recommender/bert4rec.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/sequential_recommender/bsarec.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/sequential_recommender/caser.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/sequential_recommender/cl4srec.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/sequential_recommender/core.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/sequential_recommender/duorec.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/sequential_recommender/esasrec.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/sequential_recommender/fossil.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/sequential_recommender/gru4rec.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/sequential_recommender/gsasrec.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/sequential_recommender/lightsans.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/sequential_recommender/linrec.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/sequential_recommender/narm.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/sequential_recommender/sasrec.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/sequential_recommender/stan.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/similarities.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/trainer/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/trainer/logger_callbacks.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/trainer/objectives.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/trainer/runtime.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/trainer/scheduler_wrapper.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/trainer/search_algorithm_wrapper.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/trainer/trainer.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/unpersonalized_recommender/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/unpersonalized_recommender/pop.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/recommenders/unpersonalized_recommender/random.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/run.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/serve.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/serving/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/serving/api.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/serving/app.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/serving/catalogue.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/serving/context.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/serving/deployments.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/serving/errors.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/serving/mcp.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/serving/payload.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/serving/schemas.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/serving/servable.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/callback.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/config/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/config/dashboard_configuration.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/config/estimate_configuration.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/config/evaluation_configuration.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/config/general_configuration.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/config/model_configuration.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/config/reader_configuration.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/config/recommender_model_config/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/autoencoder_config.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/graph_based_config.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/knn_config.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/latent_factor_config.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/neural_config.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/config/recommender_model_config/content_based_config.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/config/recommender_model_config/context_aware_config.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/config/recommender_model_config/hybrid_config.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/config/recommender_model_config/knowledge_aware_config.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/config/recommender_model_config/multimodal_config.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/config/recommender_model_config/sequential_model_config.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/config/recommender_model_config/unpersonalized_config.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/config/rerank_configuration.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/config/run_configuration.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/config/search_space_wrapper.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/config/serving_configuration.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/config/splitter_configuration.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/config/training_configuration.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/config/writer_configuration.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/enums.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/helpers.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/logger/__init__.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/logger/logger.py +0 -0
- {warprec-2.2.0 → warprec-2.2.1}/warprec/utils/pause.py +0 -0
|
@@ -29,6 +29,21 @@ from warprec.utils.logger import logger
|
|
|
29
29
|
from warprec.utils.registry import metric_registry
|
|
30
30
|
|
|
31
31
|
|
|
32
|
+
def _sub_metric_names(name: str, params: Dict[str, Any]) -> List[str]:
|
|
33
|
+
"""The metrics a configured metric is built from, if it is registered.
|
|
34
|
+
|
|
35
|
+
Args:
|
|
36
|
+
name (str): The configured metric.
|
|
37
|
+
params (Dict[str, Any]): Its parameters.
|
|
38
|
+
|
|
39
|
+
Returns:
|
|
40
|
+
List[str]: The names of the metrics it builds.
|
|
41
|
+
"""
|
|
42
|
+
if name.upper() not in metric_registry.list_registered():
|
|
43
|
+
return []
|
|
44
|
+
return metric_registry.get_class(name).sub_metric_names(params)
|
|
45
|
+
|
|
46
|
+
|
|
32
47
|
class Evaluator:
|
|
33
48
|
"""Evaluator class will evaluate a trained model on a given
|
|
34
49
|
set of metrics, taking into account the cutoff.
|
|
@@ -140,9 +155,67 @@ class Evaluator:
|
|
|
140
155
|
check_stash(
|
|
141
156
|
additional_data, {"k", *self.common_params, *METRIC_ARGUMENTS}, "metric"
|
|
142
157
|
)
|
|
158
|
+
self._check_stash_parameters(additional_data, metric_list, complex_metrics)
|
|
143
159
|
self.common_params.update(additional_data)
|
|
144
160
|
self._init_metrics(metric_list, complex_metrics)
|
|
145
161
|
|
|
162
|
+
@staticmethod
|
|
163
|
+
def _check_stash_parameters(
|
|
164
|
+
stash: Dict[str, Any],
|
|
165
|
+
metric_list: List[str],
|
|
166
|
+
complex_metrics: Optional[List[ComplexMetricConfig]],
|
|
167
|
+
) -> None:
|
|
168
|
+
"""Refuse a stash entry that would set a parameter already set.
|
|
169
|
+
|
|
170
|
+
Every metric receives the whole stash as keyword arguments. An entry
|
|
171
|
+
named like a parameter a configured metric (or a metric it is built
|
|
172
|
+
from) takes from WarpRec, e.g. EPC's 'relevance', would silently set it
|
|
173
|
+
for every such metric, and one named like a parameter the
|
|
174
|
+
configuration gives a metric would clash with it. An entry named like
|
|
175
|
+
a parameter only a metric of your own declares is the way that metric
|
|
176
|
+
receives it, and is passed on.
|
|
177
|
+
|
|
178
|
+
Args:
|
|
179
|
+
stash (Dict[str, Any]): The stash.
|
|
180
|
+
metric_list (List[str]): The metrics configured by name.
|
|
181
|
+
complex_metrics (Optional[List[ComplexMetricConfig]]): The metrics
|
|
182
|
+
configured with parameters.
|
|
183
|
+
|
|
184
|
+
Raises:
|
|
185
|
+
ExtensionError: If a stash entry has the name of such a parameter,
|
|
186
|
+
naming the entry and the configured metrics it would reach.
|
|
187
|
+
"""
|
|
188
|
+
if not stash:
|
|
189
|
+
return
|
|
190
|
+
configured: List[Tuple[str, Dict[str, Any]]] = [
|
|
191
|
+
(name, {}) for name in metric_list
|
|
192
|
+
] + [(metric.name, metric.params) for metric in complex_metrics or []]
|
|
193
|
+
|
|
194
|
+
clashes: Dict[str, List[str]] = {}
|
|
195
|
+
for name, params in configured:
|
|
196
|
+
classes = []
|
|
197
|
+
for metric_name in [name, *_sub_metric_names(name, params)]:
|
|
198
|
+
if metric_name.upper() in metric_registry.list_registered():
|
|
199
|
+
classes.append(metric_registry.get_class(metric_name))
|
|
200
|
+
for key in stash:
|
|
201
|
+
if key in params or any(c.warprec_parameter(key) for c in classes):
|
|
202
|
+
clashes.setdefault(key, [])
|
|
203
|
+
if name not in clashes[key]:
|
|
204
|
+
clashes[key].append(name)
|
|
205
|
+
|
|
206
|
+
if clashes:
|
|
207
|
+
details = "; ".join(
|
|
208
|
+
f"{key!r} reaches {', '.join(names)}"
|
|
209
|
+
for key, names in sorted(clashes.items())
|
|
210
|
+
)
|
|
211
|
+
raise ExtensionError(
|
|
212
|
+
"A stash entry has the name of a parameter WarpRec or the "
|
|
213
|
+
"configuration sets for a configured metric, and every metric "
|
|
214
|
+
f"receives the stash, so it would set that parameter: {details}. "
|
|
215
|
+
"Rename the entry; a metric of your own receives an entry by "
|
|
216
|
+
"declaring a parameter of the entry's name."
|
|
217
|
+
)
|
|
218
|
+
|
|
146
219
|
def _init_metrics(
|
|
147
220
|
self, metric_list: List[str], complex_metrics: List[ComplexMetricConfig] = None
|
|
148
221
|
):
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import inspect
|
|
2
|
+
from typing import Any, Dict, List
|
|
2
3
|
|
|
3
4
|
import torch
|
|
4
5
|
from torch import Tensor
|
|
@@ -72,6 +73,21 @@ class F1(TopKMetric):
|
|
|
72
73
|
self.metric_instance_1.components | self.metric_instance_2.components
|
|
73
74
|
)
|
|
74
75
|
|
|
76
|
+
@classmethod
|
|
77
|
+
def sub_metric_names(cls, params: Dict[str, Any]) -> List[str]:
|
|
78
|
+
"""The two metrics combined, which receive the keyword arguments.
|
|
79
|
+
|
|
80
|
+
Args:
|
|
81
|
+
params (Dict[str, Any]): The parameters it is configured with.
|
|
82
|
+
|
|
83
|
+
Returns:
|
|
84
|
+
List[str]: The two metrics' names.
|
|
85
|
+
"""
|
|
86
|
+
defaults = inspect.signature(cls.__init__).parameters
|
|
87
|
+
return [
|
|
88
|
+
params.get(key, defaults[key].default) for key in ("metric_1", "metric_2")
|
|
89
|
+
]
|
|
90
|
+
|
|
75
91
|
def update(self, preds: Tensor, user_indices: Tensor, **kwargs: Any):
|
|
76
92
|
"""Updates the metric state with the new batch of predictions."""
|
|
77
93
|
# Update first metric
|
|
@@ -110,5 +126,5 @@ class F1(TopKMetric):
|
|
|
110
126
|
def name(self):
|
|
111
127
|
"""The name of the metric customized based on the metrics compared."""
|
|
112
128
|
if self.metric_1 == "Precision" and self.metric_2 == "Recall":
|
|
113
|
-
return self.
|
|
114
|
-
return f"
|
|
129
|
+
return self.registered_name()
|
|
130
|
+
return f"{self.registered_name()}[{self.metric_1}, {self.metric_2}]"
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import inspect
|
|
1
2
|
from abc import abstractmethod, ABC
|
|
2
|
-
from typing import Any, Tuple, Set, Optional
|
|
3
|
+
from typing import Any, Dict, List, Tuple, Set, Optional
|
|
3
4
|
|
|
4
5
|
import torch
|
|
5
6
|
from torch import Tensor
|
|
6
7
|
from torchmetrics import Metric
|
|
7
8
|
from warprec.errors import ExtensionError
|
|
8
9
|
from warprec.utils.enums import MetricBlock
|
|
10
|
+
from warprec.utils.registry import metric_registry
|
|
9
11
|
|
|
10
12
|
|
|
11
13
|
class BaseMetric(Metric, ABC):
|
|
@@ -302,9 +304,73 @@ class BaseMetric(Metric, ABC):
|
|
|
302
304
|
)
|
|
303
305
|
|
|
304
306
|
@property
|
|
305
|
-
def name(self):
|
|
306
|
-
"""The name
|
|
307
|
-
|
|
307
|
+
def name(self) -> str:
|
|
308
|
+
"""The name the metric reports its results under.
|
|
309
|
+
|
|
310
|
+
Returns:
|
|
311
|
+
str: The name the metric is registered, and configured, under.
|
|
312
|
+
"""
|
|
313
|
+
return self.registered_name()
|
|
314
|
+
|
|
315
|
+
@classmethod
|
|
316
|
+
def registered_name(cls) -> str:
|
|
317
|
+
"""The name the class is registered under, as it was written.
|
|
318
|
+
|
|
319
|
+
A class registered under a name of its own, e.g. 'MyName' on a class
|
|
320
|
+
Foo, reports under that name, the one the configuration names it by,
|
|
321
|
+
rather than its class name. Every built-in metric is registered under
|
|
322
|
+
its class name. A class that is not registered reports under its
|
|
323
|
+
class name.
|
|
324
|
+
|
|
325
|
+
Returns:
|
|
326
|
+
str: The registered name, or the class name.
|
|
327
|
+
"""
|
|
328
|
+
return metric_registry.spelled_name(cls) or cls.__name__
|
|
329
|
+
|
|
330
|
+
@classmethod
|
|
331
|
+
def warprec_parameter(cls, name: str) -> bool:
|
|
332
|
+
"""Whether a constructor parameter of the metric is one of WarpRec's.
|
|
333
|
+
|
|
334
|
+
The stash reaches every metric as keyword arguments, so an entry named
|
|
335
|
+
like a parameter sets it. That is how a metric of your own receives an
|
|
336
|
+
entry, by declaring a parameter of its name; a parameter a built-in
|
|
337
|
+
metric declares (EPC's 'relevance') is WarpRec's, set by its default or
|
|
338
|
+
the configuration, and an entry would change it without a word. The
|
|
339
|
+
parameter belongs to the class nearest in the hierarchy that names it,
|
|
340
|
+
so a metric of your own may declare one a built-in it extends has.
|
|
341
|
+
|
|
342
|
+
Args:
|
|
343
|
+
name (str): The parameter.
|
|
344
|
+
|
|
345
|
+
Returns:
|
|
346
|
+
bool: True if the nearest class naming the parameter is WarpRec's.
|
|
347
|
+
"""
|
|
348
|
+
for klass in cls.__mro__:
|
|
349
|
+
init = klass.__dict__.get("__init__")
|
|
350
|
+
if init is None:
|
|
351
|
+
continue
|
|
352
|
+
try:
|
|
353
|
+
parameter = inspect.signature(init).parameters.get(name)
|
|
354
|
+
except (TypeError, ValueError):
|
|
355
|
+
continue
|
|
356
|
+
if parameter is not None and parameter.kind not in (
|
|
357
|
+
parameter.VAR_POSITIONAL,
|
|
358
|
+
parameter.VAR_KEYWORD,
|
|
359
|
+
):
|
|
360
|
+
return klass.__module__.split(".")[0] == "warprec"
|
|
361
|
+
return False
|
|
362
|
+
|
|
363
|
+
@classmethod
|
|
364
|
+
def sub_metric_names(cls, params: Dict[str, Any]) -> List[str]:
|
|
365
|
+
"""The metrics this one builds and hands its keyword arguments to.
|
|
366
|
+
|
|
367
|
+
Args:
|
|
368
|
+
params (Dict[str, Any]): The parameters it is configured with.
|
|
369
|
+
|
|
370
|
+
Returns:
|
|
371
|
+
List[str]: Their names; none for a metric that builds none.
|
|
372
|
+
"""
|
|
373
|
+
return []
|
|
308
374
|
|
|
309
375
|
@property
|
|
310
376
|
def components(self) -> Set[MetricBlock]:
|
|
@@ -85,5 +85,5 @@ class LongTailMetric(UserAverageTopKMetric):
|
|
|
85
85
|
def name(self):
|
|
86
86
|
"""The name of the metric."""
|
|
87
87
|
if self.pop_ratio == 0.8:
|
|
88
|
-
return self.
|
|
89
|
-
return f"{self.
|
|
88
|
+
return self.registered_name()
|
|
89
|
+
return f"{self.registered_name()}[Pop{int(self.pop_ratio * 100)}%]"
|
|
@@ -123,5 +123,5 @@ class PopREO(TopKMetric):
|
|
|
123
123
|
def name(self):
|
|
124
124
|
"""The name of the metric."""
|
|
125
125
|
if self.pop_ratio == 0.8:
|
|
126
|
-
return self.
|
|
127
|
-
return f"
|
|
126
|
+
return self.registered_name()
|
|
127
|
+
return f"{self.registered_name()}[Pop{int(self.pop_ratio * 100)}%]"
|
|
@@ -121,5 +121,5 @@ class PopRSP(TopKMetric):
|
|
|
121
121
|
def name(self):
|
|
122
122
|
"""The name of the metric."""
|
|
123
123
|
if self.pop_ratio == 0.8:
|
|
124
|
-
return self.
|
|
125
|
-
return f"
|
|
124
|
+
return self.registered_name()
|
|
125
|
+
return f"{self.registered_name()}[Pop{int(self.pop_ratio * 100)}%]"
|
{warprec-2.2.0 → warprec-2.2.1}/warprec/evaluation/metrics/multiobjective/euclideandistance.py
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Any, List
|
|
1
|
+
from typing import Any, Dict, List
|
|
2
2
|
import torch
|
|
3
3
|
from torch import Tensor, nn
|
|
4
4
|
from warprec.errors import ConfigurationError, EvaluationError
|
|
@@ -77,6 +77,18 @@ class EucDistance(TopKMetric):
|
|
|
77
77
|
|
|
78
78
|
self._REQUIRED_COMPONENTS = required_blocks
|
|
79
79
|
|
|
80
|
+
@classmethod
|
|
81
|
+
def sub_metric_names(cls, params: Dict[str, Any]) -> List[str]:
|
|
82
|
+
"""The metrics combined, which receive the keyword arguments.
|
|
83
|
+
|
|
84
|
+
Args:
|
|
85
|
+
params (Dict[str, Any]): The parameters it is configured with.
|
|
86
|
+
|
|
87
|
+
Returns:
|
|
88
|
+
List[str]: The names in 'metric_names'.
|
|
89
|
+
"""
|
|
90
|
+
return list(params.get("metric_names") or [])
|
|
91
|
+
|
|
80
92
|
def reset(self) -> None:
|
|
81
93
|
"""Reset the sub-metrics along with the composite.
|
|
82
94
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Any, List
|
|
1
|
+
from typing import Any, Dict, List
|
|
2
2
|
import torch
|
|
3
3
|
from torch import Tensor, nn
|
|
4
4
|
from warprec.errors import ConfigurationError, EvaluationError
|
|
@@ -83,6 +83,18 @@ class Hypervolume(TopKMetric):
|
|
|
83
83
|
|
|
84
84
|
self._REQUIRED_COMPONENTS = required_blocks
|
|
85
85
|
|
|
86
|
+
@classmethod
|
|
87
|
+
def sub_metric_names(cls, params: Dict[str, Any]) -> List[str]:
|
|
88
|
+
"""The metrics combined, which receive the keyword arguments.
|
|
89
|
+
|
|
90
|
+
Args:
|
|
91
|
+
params (Dict[str, Any]): The parameters it is configured with.
|
|
92
|
+
|
|
93
|
+
Returns:
|
|
94
|
+
List[str]: The names in 'metric_names'.
|
|
95
|
+
"""
|
|
96
|
+
return list(params.get("metric_names") or [])
|
|
97
|
+
|
|
86
98
|
def reset(self) -> None:
|
|
87
99
|
"""Reset the sub-metrics along with the composite.
|
|
88
100
|
|
|
@@ -110,5 +110,5 @@ class NoveltyProfileMetric(UserAverageTopKMetric):
|
|
|
110
110
|
def name(self):
|
|
111
111
|
"""The name of the metric."""
|
|
112
112
|
if self.relevance == "binary":
|
|
113
|
-
return self.
|
|
114
|
-
return f"{self.
|
|
113
|
+
return self.registered_name()
|
|
114
|
+
return f"{self.registered_name()}[{self.relevance}]"
|
|
@@ -7,6 +7,7 @@ from dataclasses import asdict
|
|
|
7
7
|
from typing import Any, Dict, Iterator, Optional
|
|
8
8
|
|
|
9
9
|
from codecarbon import EmissionsTracker
|
|
10
|
+
from codecarbon.output_methods.base_output import BaseOutput
|
|
10
11
|
from codecarbon.output_methods.emissions_data import EmissionsData
|
|
11
12
|
from codecarbon.output_methods.file import FileOutput
|
|
12
13
|
from ray import tune
|
|
@@ -62,6 +63,33 @@ class WarpRecMLflowLoggerCallback(MLflowLoggerCallback):
|
|
|
62
63
|
TRIAL_EMISSIONS_DIR = ".codecarbon_trials"
|
|
63
64
|
|
|
64
65
|
|
|
66
|
+
class _TrialRow(BaseOutput):
|
|
67
|
+
"""Keep the row a trial's tracker measured, for the driver to write.
|
|
68
|
+
|
|
69
|
+
CodeCarbon samples the CPU and RAM utilization and the RAM used every
|
|
70
|
+
second, and averages them into the row, only while its tracker has an
|
|
71
|
+
output to write to. The trial's tracker writes nowhere itself, so without
|
|
72
|
+
one the row read 0 for all three.
|
|
73
|
+
|
|
74
|
+
Attributes:
|
|
75
|
+
total (Optional[EmissionsData]): The row, once the tracker stopped.
|
|
76
|
+
"""
|
|
77
|
+
|
|
78
|
+
total: Optional[EmissionsData]
|
|
79
|
+
|
|
80
|
+
def __init__(self) -> None:
|
|
81
|
+
self.total = None
|
|
82
|
+
|
|
83
|
+
def out(self, total: EmissionsData, delta: EmissionsData) -> None:
|
|
84
|
+
"""Keep the row the tracker writes when it stops.
|
|
85
|
+
|
|
86
|
+
Args:
|
|
87
|
+
total (EmissionsData): The emissions since the tracker started.
|
|
88
|
+
delta (EmissionsData): The emissions since the last write.
|
|
89
|
+
"""
|
|
90
|
+
self.total = total
|
|
91
|
+
|
|
92
|
+
|
|
65
93
|
@contextmanager
|
|
66
94
|
def trial_emissions(
|
|
67
95
|
settings: Optional[Dict[str, Any]], trial_id: Optional[str]
|
|
@@ -87,6 +115,7 @@ def trial_emissions(
|
|
|
87
115
|
yield
|
|
88
116
|
return
|
|
89
117
|
|
|
118
|
+
row = _TrialRow()
|
|
90
119
|
tracker = EmissionsTracker(
|
|
91
120
|
project_name=trial_id,
|
|
92
121
|
save_to_api=settings["save_to_api"],
|
|
@@ -94,13 +123,14 @@ def trial_emissions(
|
|
|
94
123
|
output_dir=settings["output_dir"],
|
|
95
124
|
tracking_mode="process",
|
|
96
125
|
log_level="error",
|
|
126
|
+
output_handlers=[row],
|
|
97
127
|
)
|
|
98
128
|
tracker.start()
|
|
99
129
|
try:
|
|
100
130
|
yield
|
|
101
131
|
finally:
|
|
102
132
|
tracker.stop()
|
|
103
|
-
data =
|
|
133
|
+
data = row.total
|
|
104
134
|
if settings["save_to_file"] and data is not None:
|
|
105
135
|
folder = os.path.join(settings["output_dir"], TRIAL_EMISSIONS_DIR)
|
|
106
136
|
os.makedirs(folder, exist_ok=True)
|
|
@@ -1,5 +1,17 @@
|
|
|
1
|
+
import difflib
|
|
1
2
|
from pathlib import Path
|
|
2
|
-
from
|
|
3
|
+
from types import UnionType
|
|
4
|
+
from typing import (
|
|
5
|
+
Any,
|
|
6
|
+
Type,
|
|
7
|
+
TypeVar,
|
|
8
|
+
Optional,
|
|
9
|
+
List,
|
|
10
|
+
Tuple,
|
|
11
|
+
Union,
|
|
12
|
+
get_args,
|
|
13
|
+
get_origin,
|
|
14
|
+
)
|
|
3
15
|
|
|
4
16
|
import yaml
|
|
5
17
|
from pydantic import BaseModel, ValidationError
|
|
@@ -79,6 +91,9 @@ def read_configuration_file(path: Union[str, Path], schema: Type[T], kind: str)
|
|
|
79
91
|
try:
|
|
80
92
|
with open(path, "r", encoding="utf-8") as file:
|
|
81
93
|
data = yaml.safe_load(file) or {}
|
|
94
|
+
# Before validating, so that a misspelled required section is named
|
|
95
|
+
# next to the error its absence raises.
|
|
96
|
+
warn_unknown_keys(data, schema)
|
|
82
97
|
return schema.model_validate(data)
|
|
83
98
|
except ValidationError as error:
|
|
84
99
|
message, errors = ConfigurationError.describe_validation(
|
|
@@ -89,6 +104,165 @@ def read_configuration_file(path: Union[str, Path], schema: Type[T], kind: str)
|
|
|
89
104
|
raise DataNotFoundError(str(error)) from error
|
|
90
105
|
|
|
91
106
|
|
|
107
|
+
def warn_unknown_keys(data: Any, schema: Type[BaseModel]) -> None:
|
|
108
|
+
"""Log every key of a configuration that no section reads.
|
|
109
|
+
|
|
110
|
+
Pydantic ignores such a key, so a misspelled one leaves the run on the
|
|
111
|
+
default without a word. Each is logged once, by its dotted path, with the
|
|
112
|
+
closest key its section does read. A section that accepts any key (a
|
|
113
|
+
model's hyperparameters, which the model checks itself) or refuses unknown
|
|
114
|
+
ones (the serving configuration) is left alone, and so are the free-form
|
|
115
|
+
dictionaries handed on as they are (callback kwargs, optimizer, scheduler,
|
|
116
|
+
re-ranker and complex metric params, MLflow tags).
|
|
117
|
+
|
|
118
|
+
A schema may hold two class attributes the walk reads: 'section_schemas',
|
|
119
|
+
mapping a field to the type its raw value is walked as when the field is
|
|
120
|
+
declared looser than that, and 'pipeline_sections', mapping every
|
|
121
|
+
top-level section any pipeline reads to its type. One file may serve
|
|
122
|
+
several pipelines, so a section only another pipeline reads is not
|
|
123
|
+
reported, though the keys inside it are checked like any other: a key no
|
|
124
|
+
pipeline reads is a typo whichever pipeline loads the file.
|
|
125
|
+
|
|
126
|
+
Args:
|
|
127
|
+
data (Any): The configuration as read from the file.
|
|
128
|
+
schema (Type[BaseModel]): The pydantic model the file must satisfy.
|
|
129
|
+
"""
|
|
130
|
+
for key, meant in _unknown_keys(data, schema, ""):
|
|
131
|
+
message = (
|
|
132
|
+
f"The configuration key '{key}' is not one WarpRec reads and is ignored."
|
|
133
|
+
)
|
|
134
|
+
if meant is not None:
|
|
135
|
+
message += f" Did you mean '{meant}'?"
|
|
136
|
+
logger.attention(message)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def _unknown_keys(
|
|
140
|
+
data: Any, schema: Type[BaseModel], path: str
|
|
141
|
+
) -> List[Tuple[str, Optional[str]]]:
|
|
142
|
+
"""The keys of one section its schema does not read, and their closest.
|
|
143
|
+
|
|
144
|
+
Args:
|
|
145
|
+
data (Any): The section as read from the file.
|
|
146
|
+
schema (Type[BaseModel]): The pydantic model of the section.
|
|
147
|
+
path (str): The dotted path of the section, empty at the top.
|
|
148
|
+
|
|
149
|
+
Returns:
|
|
150
|
+
List[Tuple[str, Optional[str]]]: Each unknown key's dotted path, with
|
|
151
|
+
the dotted path of the closest key the section reads, or None.
|
|
152
|
+
"""
|
|
153
|
+
if not isinstance(data, dict):
|
|
154
|
+
return []
|
|
155
|
+
|
|
156
|
+
fields = schema.model_fields
|
|
157
|
+
known = {
|
|
158
|
+
name: info
|
|
159
|
+
for field, info in fields.items()
|
|
160
|
+
for name in {field, info.alias or field}
|
|
161
|
+
}
|
|
162
|
+
overrides = getattr(schema, "section_schemas", {})
|
|
163
|
+
others = getattr(schema, "pipeline_sections", {})
|
|
164
|
+
prefix = f"{path}." if path else ""
|
|
165
|
+
found: List[Tuple[str, Optional[str]]] = []
|
|
166
|
+
|
|
167
|
+
for key, value in data.items():
|
|
168
|
+
if not isinstance(key, str):
|
|
169
|
+
continue
|
|
170
|
+
info = known.get(key)
|
|
171
|
+
if info is None and key in others:
|
|
172
|
+
# A section another pipeline reads: checked, not reported.
|
|
173
|
+
found.extend(_unknown_in_value(value, others[key], prefix + key))
|
|
174
|
+
continue
|
|
175
|
+
if info is None:
|
|
176
|
+
if schema.model_config.get("extra") in ("allow", "forbid"):
|
|
177
|
+
continue
|
|
178
|
+
close = difflib.get_close_matches(key, [*known, *others], n=1)
|
|
179
|
+
found.append((prefix + key, prefix + close[0] if close else None))
|
|
180
|
+
continue
|
|
181
|
+
annotation = overrides.get(key, info.annotation)
|
|
182
|
+
found.extend(_unknown_in_value(value, annotation, prefix + key))
|
|
183
|
+
|
|
184
|
+
return found
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def _unknown_in_value(
|
|
188
|
+
value: Any, annotation: Any, path: str
|
|
189
|
+
) -> List[Tuple[str, Optional[str]]]:
|
|
190
|
+
"""The unknown keys inside one value, walked as its annotation says.
|
|
191
|
+
|
|
192
|
+
Args:
|
|
193
|
+
value (Any): The value as read from the file.
|
|
194
|
+
annotation (Any): The type the value is declared with.
|
|
195
|
+
path (str): The dotted path of the value.
|
|
196
|
+
|
|
197
|
+
Returns:
|
|
198
|
+
List[Tuple[str, Optional[str]]]: As _unknown_keys.
|
|
199
|
+
"""
|
|
200
|
+
origin = get_origin(annotation)
|
|
201
|
+
|
|
202
|
+
if origin in (Union, UnionType):
|
|
203
|
+
# Optional[X] and the like: walk the value as the one alternative of
|
|
204
|
+
# its shape, a section or mapping for a mapping, a list for a list.
|
|
205
|
+
shape = _shape_of_value(value)
|
|
206
|
+
for alternative in get_args(annotation):
|
|
207
|
+
if shape is not None and _shape_of(alternative) is shape:
|
|
208
|
+
return _unknown_in_value(value, alternative, path)
|
|
209
|
+
return []
|
|
210
|
+
|
|
211
|
+
if isinstance(annotation, type) and issubclass(annotation, BaseModel):
|
|
212
|
+
return _unknown_keys(value, annotation, path)
|
|
213
|
+
|
|
214
|
+
args = get_args(annotation)
|
|
215
|
+
if origin is dict and isinstance(value, dict) and len(args) == 2:
|
|
216
|
+
return [
|
|
217
|
+
unknown
|
|
218
|
+
for key, entry in value.items()
|
|
219
|
+
for unknown in _unknown_in_value(entry, args[1], f"{path}.{key}")
|
|
220
|
+
]
|
|
221
|
+
|
|
222
|
+
if origin is list and isinstance(value, list) and args:
|
|
223
|
+
return [
|
|
224
|
+
unknown
|
|
225
|
+
for index, entry in enumerate(value)
|
|
226
|
+
for unknown in _unknown_in_value(entry, args[0], f"{path}[{index}]")
|
|
227
|
+
]
|
|
228
|
+
|
|
229
|
+
return []
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
def _shape_of(annotation: Any) -> Optional[type]:
|
|
233
|
+
"""The container a value of the annotation is read from in a YAML file.
|
|
234
|
+
|
|
235
|
+
Args:
|
|
236
|
+
annotation (Any): A type, possibly generic.
|
|
237
|
+
|
|
238
|
+
Returns:
|
|
239
|
+
Optional[type]: dict for a section or a mapping, list for a list,
|
|
240
|
+
None for anything else.
|
|
241
|
+
"""
|
|
242
|
+
if isinstance(annotation, type) and issubclass(annotation, BaseModel):
|
|
243
|
+
return dict
|
|
244
|
+
origin = get_origin(annotation)
|
|
245
|
+
if origin in (dict, list):
|
|
246
|
+
return origin
|
|
247
|
+
return None
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def _shape_of_value(value: Any) -> Optional[type]:
|
|
251
|
+
"""The container a value read from a YAML file is.
|
|
252
|
+
|
|
253
|
+
Args:
|
|
254
|
+
value (Any): The value.
|
|
255
|
+
|
|
256
|
+
Returns:
|
|
257
|
+
Optional[type]: dict for a mapping, list for a list, None otherwise.
|
|
258
|
+
"""
|
|
259
|
+
if isinstance(value, dict):
|
|
260
|
+
return dict
|
|
261
|
+
if isinstance(value, list):
|
|
262
|
+
return list
|
|
263
|
+
return None
|
|
264
|
+
|
|
265
|
+
|
|
92
266
|
def check_separator(sep: str) -> str:
|
|
93
267
|
"""This method checks the separator, if it's not in a correct format
|
|
94
268
|
then it is set to the default separator.
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import copy
|
|
2
|
+
import difflib
|
|
2
3
|
import os
|
|
3
4
|
import sys
|
|
4
5
|
import importlib
|
|
5
6
|
from pathlib import Path
|
|
6
|
-
from typing import Dict, Any, List
|
|
7
|
+
from typing import ClassVar, Dict, Any, List
|
|
7
8
|
|
|
8
9
|
from pydantic import BaseModel, model_validator, Field
|
|
9
10
|
from warprec.errors import ConfigurationError, RegistryError
|
|
@@ -38,6 +39,13 @@ class WarpRecConfiguration(BaseModel):
|
|
|
38
39
|
"""Definition of WarpRec base configuration file structure.
|
|
39
40
|
|
|
40
41
|
Attributes:
|
|
42
|
+
section_schemas (ClassVar[Dict[str, Any]]): The type each model's raw
|
|
43
|
+
parameters are checked against for keys no section reads: they
|
|
44
|
+
are validated by the model's own class, so the field is loose.
|
|
45
|
+
pipeline_sections (ClassVar[Dict[str, Any]]): Every top-level section
|
|
46
|
+
any pipeline reads, with its type. A file may serve several
|
|
47
|
+
pipelines, so a section only another one reads is not reported as
|
|
48
|
+
unknown, and its keys are still checked against its type.
|
|
41
49
|
reader (ReaderConfig): Configuration of the reading process.
|
|
42
50
|
filtering (Dict[str, dict]): The dictionary containing filtering
|
|
43
51
|
information in the format {filter_name: dict{param_1: value, param_2: value, ...}, ...}
|
|
@@ -48,6 +56,22 @@ class WarpRecConfiguration(BaseModel):
|
|
|
48
56
|
rerank (RerankConfig): The re-ranking applied to every list produced.
|
|
49
57
|
"""
|
|
50
58
|
|
|
59
|
+
section_schemas: ClassVar[Dict[str, Any]] = {"models": Dict[str, RecomModel]}
|
|
60
|
+
pipeline_sections: ClassVar[Dict[str, Any]] = {
|
|
61
|
+
"reader": ReaderConfig,
|
|
62
|
+
"filtering": Dict[str, dict],
|
|
63
|
+
"models": Dict[str, RecomModel],
|
|
64
|
+
"general": GeneralConfig,
|
|
65
|
+
"training": TrainingConfig,
|
|
66
|
+
"rerank": RerankConfig,
|
|
67
|
+
"writer": WriterConfig,
|
|
68
|
+
"splitter": SplittingConfig,
|
|
69
|
+
"dashboard": DashboardConfig,
|
|
70
|
+
"evaluation": EvaluationConfig,
|
|
71
|
+
"run": WarpRecRunConfig,
|
|
72
|
+
"estimate": EstimateConfig,
|
|
73
|
+
}
|
|
74
|
+
|
|
51
75
|
reader: ReaderConfig
|
|
52
76
|
filtering: Dict[str, dict] = None
|
|
53
77
|
models: Dict[str, dict]
|
|
@@ -238,6 +262,7 @@ class WarpRecConfiguration(BaseModel):
|
|
|
238
262
|
"not in parameter registry. The model will be loaded but the "
|
|
239
263
|
"hyperparameter will not be validated."
|
|
240
264
|
)
|
|
265
|
+
self._warn_unread_hyperparameters(model_name, model_data)
|
|
241
266
|
return RecomModel(**copy.deepcopy(model_data))
|
|
242
267
|
|
|
243
268
|
# The validators edit the lists they are handed, and the values as
|
|
@@ -277,6 +302,32 @@ class WarpRecConfiguration(BaseModel):
|
|
|
277
302
|
|
|
278
303
|
return model_class
|
|
279
304
|
|
|
305
|
+
@staticmethod
|
|
306
|
+
def _warn_unread_hyperparameters(model_name: str, model_data: dict) -> None:
|
|
307
|
+
"""Log the keys a model without a parameter class will not read.
|
|
308
|
+
|
|
309
|
+
Such a model sets only the hyperparameters it annotates, so any other
|
|
310
|
+
key is dropped without a word. A model with a parameter class refuses
|
|
311
|
+
it instead, when the class validates the parameters.
|
|
312
|
+
|
|
313
|
+
Args:
|
|
314
|
+
model_name (str): The name the model is configured under.
|
|
315
|
+
model_data (dict): The parameters written for it.
|
|
316
|
+
"""
|
|
317
|
+
accepted = model_registry.get_class(model_name).hyperparameter_names()
|
|
318
|
+
reserved = {"meta", "optimization", "early_stopping", "fold"}
|
|
319
|
+
for key in model_data:
|
|
320
|
+
if key in reserved or key in accepted:
|
|
321
|
+
continue
|
|
322
|
+
message = (
|
|
323
|
+
f"The configuration key 'models.{model_name}.{key}' is not a "
|
|
324
|
+
f"hyperparameter of {model_name} and is ignored."
|
|
325
|
+
)
|
|
326
|
+
close = difflib.get_close_matches(str(key), accepted, n=1)
|
|
327
|
+
if close:
|
|
328
|
+
message += f" Did you mean 'models.{model_name}.{close[0]}'?"
|
|
329
|
+
logger.attention(message)
|
|
330
|
+
|
|
280
331
|
def _check_modalities_exist(self, model_name: str, model_data: dict) -> None:
|
|
281
332
|
"""Validate that a model only asks for modalities the reader provides.
|
|
282
333
|
|