warprec 2.2.1__tar.gz → 2.2.3__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.
Files changed (290) hide show
  1. {warprec-2.2.1 → warprec-2.2.3}/PKG-INFO +1 -1
  2. {warprec-2.2.1 → warprec-2.2.3}/pyproject.toml +1 -1
  3. {warprec-2.2.1 → warprec-2.2.3}/warprec/data/entities/sessions.py +11 -2
  4. {warprec-2.2.1 → warprec-2.2.3}/warprec/data/filtering.py +62 -40
  5. {warprec-2.2.1 → warprec-2.2.3}/warprec/data/splitting/strategies.py +82 -47
  6. {warprec-2.2.1 → warprec-2.2.3}/warprec/data/writer/base_writer.py +43 -12
  7. {warprec-2.2.1 → warprec-2.2.3}/warprec/pipelines/common.py +98 -1
  8. {warprec-2.2.1 → warprec-2.2.3}/warprec/pipelines/estimate.py +19 -6
  9. {warprec-2.2.1 → warprec-2.2.3}/warprec/pipelines/remotes/ml.py +32 -9
  10. {warprec-2.2.1 → warprec-2.2.3}/warprec/pipelines/swarm.py +37 -14
  11. {warprec-2.2.1 → warprec-2.2.3}/warprec/pipelines/train.py +32 -13
  12. warprec-2.2.3/warprec/recommenders/trainer/dashboard_callbacks.py +176 -0
  13. warprec-2.2.3/warprec/recommenders/trainer/emissions.py +507 -0
  14. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/trainer/objectives.py +29 -1
  15. warprec-2.2.3/warprec/recommenders/trainer/timing.py +482 -0
  16. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/trainer/trainer.py +145 -15
  17. warprec-2.2.1/warprec/recommenders/trainer/dashboard_callbacks.py +0 -239
  18. {warprec-2.2.1 → warprec-2.2.3}/LICENSE +0 -0
  19. {warprec-2.2.1 → warprec-2.2.3}/README.md +0 -0
  20. {warprec-2.2.1 → warprec-2.2.3}/warprec/__init__.py +0 -0
  21. {warprec-2.2.1 → warprec-2.2.3}/warprec/common/__init__.py +0 -0
  22. {warprec-2.2.1 → warprec-2.2.3}/warprec/common/initialize.py +0 -0
  23. {warprec-2.2.1 → warprec-2.2.3}/warprec/common/run_state.py +0 -0
  24. {warprec-2.2.1 → warprec-2.2.3}/warprec/common/std_logs.py +0 -0
  25. {warprec-2.2.1 → warprec-2.2.3}/warprec/data/__init__.py +0 -0
  26. {warprec-2.2.1 → warprec-2.2.3}/warprec/data/dataset.py +0 -0
  27. {warprec-2.2.1 → warprec-2.2.3}/warprec/data/entities/__init__.py +0 -0
  28. {warprec-2.2.1 → warprec-2.2.3}/warprec/data/entities/common.py +0 -0
  29. {warprec-2.2.1 → warprec-2.2.3}/warprec/data/entities/context.py +0 -0
  30. {warprec-2.2.1 → warprec-2.2.3}/warprec/data/entities/interactions.py +0 -0
  31. {warprec-2.2.1 → warprec-2.2.3}/warprec/data/entities/knowledge.py +0 -0
  32. {warprec-2.2.1 → warprec-2.2.3}/warprec/data/entities/multimodal.py +0 -0
  33. {warprec-2.2.1 → warprec-2.2.3}/warprec/data/entities/train_structures/__init__.py +0 -0
  34. {warprec-2.2.1 → warprec-2.2.3}/warprec/data/entities/train_structures/custom_collate_fn.py +0 -0
  35. {warprec-2.2.1 → warprec-2.2.3}/warprec/data/entities/train_structures/interaction_structures.py +0 -0
  36. {warprec-2.2.1 → warprec-2.2.3}/warprec/data/entities/train_structures/session_structures.py +0 -0
  37. {warprec-2.2.1 → warprec-2.2.3}/warprec/data/entities/transactions.py +0 -0
  38. {warprec-2.2.1 → warprec-2.2.3}/warprec/data/eval_loaders.py +0 -0
  39. {warprec-2.2.1 → warprec-2.2.3}/warprec/data/ranking.py +0 -0
  40. {warprec-2.2.1 → warprec-2.2.3}/warprec/data/reader/__init__.py +0 -0
  41. {warprec-2.2.1 → warprec-2.2.3}/warprec/data/reader/azureblob_reader.py +0 -0
  42. {warprec-2.2.1 → warprec-2.2.3}/warprec/data/reader/base_reader.py +0 -0
  43. {warprec-2.2.1 → warprec-2.2.3}/warprec/data/reader/local_reader.py +0 -0
  44. {warprec-2.2.1 → warprec-2.2.3}/warprec/data/schema.py +0 -0
  45. {warprec-2.2.1 → warprec-2.2.3}/warprec/data/splitting/__init__.py +0 -0
  46. {warprec-2.2.1 → warprec-2.2.3}/warprec/data/splitting/splitter.py +0 -0
  47. {warprec-2.2.1 → warprec-2.2.3}/warprec/data/stash.py +0 -0
  48. {warprec-2.2.1 → warprec-2.2.3}/warprec/data/writer/__init__.py +0 -0
  49. {warprec-2.2.1 → warprec-2.2.3}/warprec/data/writer/azureblob_writer.py +0 -0
  50. {warprec-2.2.1 → warprec-2.2.3}/warprec/data/writer/local_writer.py +0 -0
  51. {warprec-2.2.1 → warprec-2.2.3}/warprec/errors.py +0 -0
  52. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/__init__.py +0 -0
  53. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/evaluator.py +0 -0
  54. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/factory.py +0 -0
  55. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/__init__.py +0 -0
  56. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/accuracy/__init__.py +0 -0
  57. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/accuracy/auc.py +0 -0
  58. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/accuracy/f1.py +0 -0
  59. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/accuracy/gauc.py +0 -0
  60. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/accuracy/hit_rate.py +0 -0
  61. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/accuracy/lauc.py +0 -0
  62. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/accuracy/logloss.py +0 -0
  63. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/accuracy/map.py +0 -0
  64. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/accuracy/mar.py +0 -0
  65. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/accuracy/mrr.py +0 -0
  66. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/accuracy/ndcg.py +0 -0
  67. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/accuracy/precision.py +0 -0
  68. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/accuracy/recall.py +0 -0
  69. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/base_metric.py +0 -0
  70. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/bias/__init__.py +0 -0
  71. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/bias/aclt.py +0 -0
  72. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/bias/aplt.py +0 -0
  73. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/bias/arp.py +0 -0
  74. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/bias/long_tail.py +0 -0
  75. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/bias/pop_reo.py +0 -0
  76. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/bias/pop_rsp.py +0 -0
  77. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/coverage/__init__.py +0 -0
  78. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/coverage/item_coverage.py +0 -0
  79. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/coverage/numretrieved.py +0 -0
  80. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/coverage/user_coverage.py +0 -0
  81. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/coverage/user_coverage_at_n.py +0 -0
  82. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/debiased/__init__.py +0 -0
  83. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/debiased/base.py +0 -0
  84. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/debiased/dcg.py +0 -0
  85. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/debiased/recall.py +0 -0
  86. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/diversity/__init__.py +0 -0
  87. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/diversity/gini_index.py +0 -0
  88. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/diversity/shannon_entropy.py +0 -0
  89. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/diversity/srecall.py +0 -0
  90. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/fairness/__init__.py +0 -0
  91. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/fairness/biasdisparitybd.py +0 -0
  92. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/fairness/biasdisparitybr.py +0 -0
  93. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/fairness/biasdisparitybs.py +0 -0
  94. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/fairness/itemmadranking.py +0 -0
  95. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/fairness/itemmadrating.py +0 -0
  96. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/fairness/reo.py +0 -0
  97. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/fairness/rsp.py +0 -0
  98. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/fairness/usermadranking.py +0 -0
  99. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/fairness/usermadrating.py +0 -0
  100. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/multiobjective/__init__.py +0 -0
  101. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/multiobjective/euclideandistance.py +0 -0
  102. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/multiobjective/hypervolume.py +0 -0
  103. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/novelty/__init__.py +0 -0
  104. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/novelty/efd.py +0 -0
  105. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/novelty/epc.py +0 -0
  106. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/novelty/novelty_profile.py +0 -0
  107. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/rating/__init__.py +0 -0
  108. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/rating/mae.py +0 -0
  109. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/rating/mse.py +0 -0
  110. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/metrics/rating/rmse.py +0 -0
  111. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/propensity.py +0 -0
  112. {warprec-2.2.1 → warprec-2.2.3}/warprec/evaluation/statistical_significance.py +0 -0
  113. {warprec-2.2.1 → warprec-2.2.3}/warprec/pipelines/__init__.py +0 -0
  114. {warprec-2.2.1 → warprec-2.2.3}/warprec/pipelines/design.py +0 -0
  115. {warprec-2.2.1 → warprec-2.2.3}/warprec/pipelines/eval.py +0 -0
  116. {warprec-2.2.1 → warprec-2.2.3}/warprec/pipelines/remotes/__init__.py +0 -0
  117. {warprec-2.2.1 → warprec-2.2.3}/warprec/pipelines/remotes/data.py +0 -0
  118. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/__init__.py +0 -0
  119. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/base_recommender.py +0 -0
  120. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/callbacks.py +0 -0
  121. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/__init__.py +0 -0
  122. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/__init__.py +0 -0
  123. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/cdae.py +0 -0
  124. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/diffrec.py +0 -0
  125. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/ease.py +0 -0
  126. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/elsa.py +0 -0
  127. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/macridvae.py +0 -0
  128. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/multidae.py +0 -0
  129. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/multivae.py +0 -0
  130. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/autoencoder/sansa.py +0 -0
  131. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/graph_based/__init__.py +0 -0
  132. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/graph_based/dgcf.py +0 -0
  133. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/graph_based/egcf.py +0 -0
  134. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/graph_based/esigcf.py +0 -0
  135. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/graph_based/gcmc.py +0 -0
  136. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/graph_based/graph_utils.py +0 -0
  137. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightccf.py +0 -0
  138. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgcl.py +0 -0
  139. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgcn.py +0 -0
  140. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgcnpp.py +0 -0
  141. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/graph_based/lightgode.py +0 -0
  142. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/graph_based/macrgcn.py +0 -0
  143. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/graph_based/mixrec.py +0 -0
  144. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/graph_based/ngcf.py +0 -0
  145. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/graph_based/paac.py +0 -0
  146. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/graph_based/popdcl.py +0 -0
  147. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/graph_based/recdcl.py +0 -0
  148. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/graph_based/rp3beta.py +0 -0
  149. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/graph_based/sgcl.py +0 -0
  150. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/graph_based/sgl.py +0 -0
  151. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/graph_based/simgcl.py +0 -0
  152. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/graph_based/simrec.py +0 -0
  153. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/graph_based/ultragcn.py +0 -0
  154. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/graph_based/xsimgcl.py +0 -0
  155. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/knn/__init__.py +0 -0
  156. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/knn/itemknn.py +0 -0
  157. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/knn/itemknntd.py +0 -0
  158. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/knn/userknn.py +0 -0
  159. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/knn/userknntd.py +0 -0
  160. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/__init__.py +0 -0
  161. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/admmslim.py +0 -0
  162. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/bpr.py +0 -0
  163. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/fism.py +0 -0
  164. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/ials.py +0 -0
  165. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/ials2008.py +0 -0
  166. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/macrmf.py +0 -0
  167. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/latent_factor/slim.py +0 -0
  168. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/neural/__init__.py +0 -0
  169. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/neural/convncf.py +0 -0
  170. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/neural/neumf.py +0 -0
  171. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/collaborative_filtering_recommender/neural/twotower.py +0 -0
  172. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/content_based_recommender/__init__.py +0 -0
  173. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/content_based_recommender/vsm.py +0 -0
  174. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/context_aware_recommender/__init__.py +0 -0
  175. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/context_aware_recommender/afm.py +0 -0
  176. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/context_aware_recommender/dcn.py +0 -0
  177. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/context_aware_recommender/dcnv2.py +0 -0
  178. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/context_aware_recommender/deepfm.py +0 -0
  179. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/context_aware_recommender/fm.py +0 -0
  180. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/context_aware_recommender/nfm.py +0 -0
  181. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/context_aware_recommender/wideanddeep.py +0 -0
  182. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/context_aware_recommender/xdeepfm.py +0 -0
  183. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/hybrid_recommender/__init__.py +0 -0
  184. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/hybrid_recommender/addease.py +0 -0
  185. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/hybrid_recommender/attributeitemknn.py +0 -0
  186. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/hybrid_recommender/attributeuserknn.py +0 -0
  187. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/hybrid_recommender/cease.py +0 -0
  188. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/knowledge_aware_recommender/__init__.py +0 -0
  189. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/knowledge_aware_recommender/cke.py +0 -0
  190. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/knowledge_aware_recommender/kahfm.py +0 -0
  191. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/knowledge_aware_recommender/kgat.py +0 -0
  192. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/knowledge_aware_recommender/kgcn.py +0 -0
  193. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/knowledge_aware_recommender/kgflex.py +0 -0
  194. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/knowledge_aware_recommender/kgin.py +0 -0
  195. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/knowledge_aware_recommender/knowledge_utils.py +0 -0
  196. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/knowledge_aware_recommender/ripplenet.py +0 -0
  197. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/layers.py +0 -0
  198. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/losses.py +0 -0
  199. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/lr_scheduler_wrapper.py +0 -0
  200. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/multimodal_recommender/__init__.py +0 -0
  201. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/multimodal_recommender/bm3.py +0 -0
  202. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/multimodal_recommender/freedom.py +0 -0
  203. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/multimodal_recommender/lattice.py +0 -0
  204. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/multimodal_recommender/mgcn.py +0 -0
  205. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/multimodal_recommender/mmgcn.py +0 -0
  206. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/multimodal_recommender/multimodal_utils.py +0 -0
  207. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/multimodal_recommender/vbpr.py +0 -0
  208. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/optimizer_wrapper.py +0 -0
  209. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/proxy.py +0 -0
  210. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/reranking/__init__.py +0 -0
  211. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/reranking/base.py +0 -0
  212. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/reranking/calibration.py +0 -0
  213. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/reranking/factory.py +0 -0
  214. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/reranking/mmr.py +0 -0
  215. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/sequential_recommender/__init__.py +0 -0
  216. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/sequential_recommender/bert4rec.py +0 -0
  217. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/sequential_recommender/bsarec.py +0 -0
  218. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/sequential_recommender/caser.py +0 -0
  219. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/sequential_recommender/cl4srec.py +0 -0
  220. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/sequential_recommender/core.py +0 -0
  221. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/sequential_recommender/duorec.py +0 -0
  222. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/sequential_recommender/esasrec.py +0 -0
  223. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/sequential_recommender/fossil.py +0 -0
  224. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/sequential_recommender/gru4rec.py +0 -0
  225. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/sequential_recommender/gsasrec.py +0 -0
  226. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/sequential_recommender/lightsans.py +0 -0
  227. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/sequential_recommender/linrec.py +0 -0
  228. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/sequential_recommender/narm.py +0 -0
  229. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/sequential_recommender/sasrec.py +0 -0
  230. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/sequential_recommender/stan.py +0 -0
  231. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/similarities.py +0 -0
  232. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/trainer/__init__.py +0 -0
  233. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/trainer/logger_callbacks.py +0 -0
  234. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/trainer/runtime.py +0 -0
  235. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/trainer/scheduler_wrapper.py +0 -0
  236. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/trainer/search_algorithm_wrapper.py +0 -0
  237. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/unpersonalized_recommender/__init__.py +0 -0
  238. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/unpersonalized_recommender/pop.py +0 -0
  239. {warprec-2.2.1 → warprec-2.2.3}/warprec/recommenders/unpersonalized_recommender/random.py +0 -0
  240. {warprec-2.2.1 → warprec-2.2.3}/warprec/run.py +0 -0
  241. {warprec-2.2.1 → warprec-2.2.3}/warprec/serve.py +0 -0
  242. {warprec-2.2.1 → warprec-2.2.3}/warprec/serving/__init__.py +0 -0
  243. {warprec-2.2.1 → warprec-2.2.3}/warprec/serving/api.py +0 -0
  244. {warprec-2.2.1 → warprec-2.2.3}/warprec/serving/app.py +0 -0
  245. {warprec-2.2.1 → warprec-2.2.3}/warprec/serving/catalogue.py +0 -0
  246. {warprec-2.2.1 → warprec-2.2.3}/warprec/serving/context.py +0 -0
  247. {warprec-2.2.1 → warprec-2.2.3}/warprec/serving/deployments.py +0 -0
  248. {warprec-2.2.1 → warprec-2.2.3}/warprec/serving/errors.py +0 -0
  249. {warprec-2.2.1 → warprec-2.2.3}/warprec/serving/mcp.py +0 -0
  250. {warprec-2.2.1 → warprec-2.2.3}/warprec/serving/payload.py +0 -0
  251. {warprec-2.2.1 → warprec-2.2.3}/warprec/serving/schemas.py +0 -0
  252. {warprec-2.2.1 → warprec-2.2.3}/warprec/serving/servable.py +0 -0
  253. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/__init__.py +0 -0
  254. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/callback.py +0 -0
  255. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/config/__init__.py +0 -0
  256. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/config/common.py +0 -0
  257. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/config/config.py +0 -0
  258. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/config/dashboard_configuration.py +0 -0
  259. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/config/estimate_configuration.py +0 -0
  260. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/config/evaluation_configuration.py +0 -0
  261. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/config/general_configuration.py +0 -0
  262. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/config/model_configuration.py +0 -0
  263. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/config/reader_configuration.py +0 -0
  264. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/config/recommender_model_config/__init__.py +0 -0
  265. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/__init__.py +0 -0
  266. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/autoencoder_config.py +0 -0
  267. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/graph_based_config.py +0 -0
  268. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/knn_config.py +0 -0
  269. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/latent_factor_config.py +0 -0
  270. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/config/recommender_model_config/collaborative_filtering_config/neural_config.py +0 -0
  271. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/config/recommender_model_config/content_based_config.py +0 -0
  272. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/config/recommender_model_config/context_aware_config.py +0 -0
  273. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/config/recommender_model_config/hybrid_config.py +0 -0
  274. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/config/recommender_model_config/knowledge_aware_config.py +0 -0
  275. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/config/recommender_model_config/multimodal_config.py +0 -0
  276. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/config/recommender_model_config/sequential_model_config.py +0 -0
  277. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/config/recommender_model_config/unpersonalized_config.py +0 -0
  278. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/config/rerank_configuration.py +0 -0
  279. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/config/run_configuration.py +0 -0
  280. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/config/search_space_wrapper.py +0 -0
  281. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/config/serving_configuration.py +0 -0
  282. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/config/splitter_configuration.py +0 -0
  283. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/config/training_configuration.py +0 -0
  284. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/config/writer_configuration.py +0 -0
  285. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/enums.py +0 -0
  286. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/helpers.py +0 -0
  287. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/logger/__init__.py +0 -0
  288. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/logger/logger.py +0 -0
  289. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/pause.py +0 -0
  290. {warprec-2.2.1 → warprec-2.2.3}/warprec/utils/registry.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: warprec
3
- Version: 2.2.1
3
+ Version: 2.2.3
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
@@ -61,7 +61,7 @@ warprec = "warprec.run:main"
61
61
  "warprec.serve" = "warprec.serve:main"
62
62
 
63
63
  [tool.poetry]
64
- version = "2.2.1"
64
+ version = "2.2.3"
65
65
 
66
66
  [tool.poetry.dependencies]
67
67
  python = "^3.12"
@@ -12,6 +12,7 @@ from scipy.sparse import csr_matrix
12
12
  from warprec.errors import DataError
13
13
  from warprec.data.entities.common import (
14
14
  ITEM_INDEX,
15
+ ROW_INDEX,
15
16
  USER_INDEX,
16
17
  map_to_index_space,
17
18
  seeded_dataloader,
@@ -77,6 +78,10 @@ class Sessions:
77
78
  """
78
79
  Centralized pipeline: Map IDs -> Drop Missing -> Sort by User/Time.
79
80
  Returns a cached Narwhals DataFrame.
81
+
82
+ Each user's rows are put in temporal order: the timestamp, then the
83
+ position in the file, so rows sharing a timestamp keep the order they
84
+ were read in. Without a timestamp column, file order alone is used.
80
85
  """
81
86
  if self._processed_df is not None:
82
87
  return self._processed_df
@@ -108,15 +113,19 @@ class Sessions:
108
113
  if c in self._inter_df.columns
109
114
  ]
110
115
  ),
116
+ nw.col(ROW_INDEX),
111
117
  ]
112
118
  )
113
119
 
114
- # Sort
120
+ # Sort. The joins above do not keep the input order on every backend,
121
+ # and a sort is not stable on every backend either, so the position in
122
+ # the file is the last key: it settles every tie the timestamp leaves.
115
123
  sort_cols = [self.user_label]
116
124
  if self.timestamp_label in self._inter_df.columns:
117
125
  sort_cols.append(self.timestamp_label)
126
+ sort_cols.append(ROW_INDEX)
118
127
 
119
- self._processed_df = mapped_df.sort(sort_cols)
128
+ self._processed_df = mapped_df.sort(sort_cols).drop(ROW_INDEX)
120
129
  return self._processed_df
121
130
 
122
131
  def _build_flat_structures(self):
@@ -71,6 +71,52 @@ class Filter(ABC):
71
71
  """Apply the filter to the dataset."""
72
72
  raise NotImplementedError("Subclasses should implement this method.")
73
73
 
74
+ # The columns _order_in_time attaches: a row's 1-based place in its user's
75
+ # temporal order, the user's number of rows, and the row's place in the input.
76
+ _PLACE = "__temporal_place__"
77
+ _COUNT = "__temporal_count__"
78
+ _FILE = "__file_order__"
79
+
80
+ def _order_in_time(self, dataset: DataFrame[Any]) -> DataFrame[Any]:
81
+ """Sort each user's rows into temporal order and number them in it.
82
+
83
+ Temporal order is the timestamp, then the position in the file: rows that
84
+ share a timestamp keep the order they were read in, and the most recent
85
+ row is the last one. Without a timestamp column, file order alone is used.
86
+ The number is taken from the position in the sorted frame rather than
87
+ from a rank of the timestamp: an ordinal rank gives a tie to the row that
88
+ appears first whichever way it runs, so a descending one called the
89
+ earlier of two same-second rows the most recent.
90
+
91
+ Args:
92
+ dataset (DataFrame[Any]): The dataset to order.
93
+
94
+ Returns:
95
+ DataFrame[Any]: The dataset sorted by user and temporal order, with
96
+ the row's place in its user's order, the user's number of rows
97
+ and the row's place in the input attached under ``_PLACE``,
98
+ ``_COUNT`` and ``_FILE``. A filter sorts by ``_FILE`` before it
99
+ hands the rows on, because what follows breaks ties by row order.
100
+ """
101
+ position = "__temporal_position__"
102
+ by = [self.user_label, self._FILE]
103
+ if self.timestamp_label in dataset.columns:
104
+ by.insert(1, self.timestamp_label)
105
+
106
+ ordered = (
107
+ dataset.with_row_index(name=self._FILE)
108
+ .sort(by=by)
109
+ .with_row_index(name=position)
110
+ )
111
+ return ordered.with_columns(
112
+ nw.col(position)
113
+ .rank(method="ordinal")
114
+ .over(self.user_label)
115
+ .cast(nw.Int64)
116
+ .alias(self._PLACE),
117
+ nw.len().over(self.user_label).cast(nw.Int64).alias(self._COUNT),
118
+ ).drop(position)
119
+
74
120
 
75
121
  @filter_registry.register("MinRating")
76
122
  class MinRating(Filter):
@@ -365,7 +411,8 @@ class NRoundsKCore(Filter):
365
411
  @filter_registry.register("UserHeadN")
366
412
  class UserHeadN(Filter):
367
413
  """Filter to keep only the first N interactions for each user,
368
- based on the timestamp.
414
+ based on the timestamp. Interactions sharing a timestamp keep their
415
+ order in the file.
369
416
 
370
417
  Args:
371
418
  num_interactions (int): Number of first interactions to keep for each user.
@@ -390,31 +437,19 @@ class UserHeadN(Filter):
390
437
  Returns:
391
438
  DataFrame[Any]: Filtered dataset containing only the first num_interactions for each user.
392
439
  """
393
- idx_col = "__stable_row_idx__"
394
- dataset = dataset.with_row_index(name=idx_col)
395
-
396
- if self.timestamp_label in dataset.columns:
397
- # Sort by User -> Timestamp -> Original Index (Tie-breaker)
398
- dataset = dataset.sort(by=[self.user_label, self.timestamp_label, idx_col])
399
- rank_target = self.timestamp_label
400
- else:
401
- # Sort by User -> Original Index
402
- dataset = dataset.sort(by=[self.user_label, idx_col])
403
- rank_target = idx_col
404
-
405
- # Rank is now stable because data is sorted
406
- dataset = dataset.filter(
407
- nw.col(rank_target).rank(method="ordinal").over(self.user_label)
408
- <= self.num_interactions
440
+ ordered = self._order_in_time(dataset)
441
+ return (
442
+ ordered.filter(nw.col(self._PLACE) <= self.num_interactions)
443
+ .sort(self._FILE)
444
+ .drop([self._PLACE, self._COUNT, self._FILE])
409
445
  )
410
446
 
411
- return dataset.drop(idx_col)
412
-
413
447
 
414
448
  @filter_registry.register("UserTailN")
415
449
  class UserTailN(Filter):
416
450
  """Filter to keep only the last N interactions for each user,
417
- based on the timestamp.
451
+ based on the timestamp. Interactions sharing a timestamp keep their
452
+ order in the file, the later one being the more recent.
418
453
 
419
454
  Args:
420
455
  num_interactions (int): Number of last interactions to keep for each user.
@@ -440,28 +475,15 @@ class UserTailN(Filter):
440
475
  DataFrame[Any]: Filtered dataset containing only the last
441
476
  num_interactions for each user.
442
477
  """
443
- idx_col = "__stable_row_idx__"
444
- dataset = dataset.with_row_index(name=idx_col)
445
-
446
- if self.timestamp_label in dataset.columns:
447
- # Sort by User -> Timestamp -> Original Index (Tie-breaker)
448
- dataset = dataset.sort(by=[self.user_label, self.timestamp_label, idx_col])
449
- rank_target = self.timestamp_label
450
- else:
451
- # Sort by User -> Original Index
452
- dataset = dataset.sort(by=[self.user_label, idx_col])
453
- rank_target = idx_col
454
-
455
- # Rank is now stable because data is sorted
456
- dataset = dataset.filter(
457
- nw.col(rank_target)
458
- .rank(method="ordinal", descending=True)
459
- .over(self.user_label)
460
- <= self.num_interactions
478
+ ordered = self._order_in_time(dataset)
479
+ return (
480
+ ordered.filter(
481
+ nw.col(self._PLACE) > nw.col(self._COUNT) - self.num_interactions
482
+ )
483
+ .sort(self._FILE)
484
+ .drop([self._PLACE, self._COUNT, self._FILE])
461
485
  )
462
486
 
463
- return dataset.drop(idx_col)
464
-
465
487
 
466
488
  @filter_registry.register("DropUser")
467
489
  class DropUser(Filter):
@@ -28,6 +28,11 @@ class SplittingStrategy(ABC):
28
28
  def _prepare_stable_data(self, data: FrameT) -> Tuple[DataFrame[Any], str]:
29
29
  """Helper method to ensure data has a stable row index for tie-breaking.
30
30
  Returns the modified data and the name of the index column.
31
+
32
+ Every strategy hands its halves back sorted by this index, in the order
33
+ of its input, because what follows breaks ties by row order: a
34
+ validation split, the sequences of a sequential model and the 'first'
35
+ and 'last' duplicate policies.
31
36
  """
32
37
  # Make the DataFrame eager in case of LazyFrames
33
38
  if isinstance(data, nw.LazyFrame):
@@ -38,6 +43,48 @@ class SplittingStrategy(ABC):
38
43
  index_col = "__original_row_index__"
39
44
  return materialized_data.with_row_index(name=index_col), index_col
40
45
 
46
+ def _order_in_time(
47
+ self,
48
+ data: DataFrame[Any],
49
+ user_id_label: str,
50
+ timestamp_label: str,
51
+ idx_col: str,
52
+ ) -> DataFrame[Any]:
53
+ """Sort each user's rows into temporal order and number them in it.
54
+
55
+ Temporal order is the timestamp, then the position in the file: rows that
56
+ share a timestamp keep the order they were read in, and the most recent
57
+ row is the last one. Without a timestamp column, file order alone is used.
58
+ The number is taken from the position in the sorted frame rather than
59
+ from a rank of the timestamp: an ordinal rank gives a tie to the row that
60
+ appears first whichever way it runs, so a descending one called the
61
+ earlier of two same-second rows the most recent.
62
+
63
+ Args:
64
+ data (DataFrame[Any]): The data, carrying the stable row index.
65
+ user_id_label (str): The user_id label.
66
+ timestamp_label (str): The timestamp label.
67
+ idx_col (str): The name of the stable row index column.
68
+
69
+ Returns:
70
+ DataFrame[Any]: The data sorted by user and temporal order, with
71
+ ``n_items`` (the user's number of rows) and ``rank`` (the row's
72
+ 1-based place in the user's temporal order) attached.
73
+ """
74
+ by = [user_id_label, idx_col]
75
+ if timestamp_label in data.columns:
76
+ by.insert(1, timestamp_label)
77
+
78
+ position = "__temporal_position__"
79
+ ordered = data.sort(by=by).with_row_index(name=position)
80
+ return ordered.with_columns(
81
+ n_items=nw.len().over(user_id_label).cast(nw.Int64),
82
+ rank=nw.col(position)
83
+ .rank(method="ordinal")
84
+ .over(user_id_label)
85
+ .cast(nw.Int64),
86
+ ).drop(position)
87
+
41
88
  def __call__(
42
89
  self, data: FrameT, **kwargs: Any
43
90
  ) -> List[Tuple[DataFrame[Any], DataFrame[Any]]]:
@@ -59,7 +106,8 @@ class TemporalHoldoutSplit(SplittingStrategy):
59
106
  """The definition of a temporal holdout splitting strategy.
60
107
 
61
108
  In case the timestamp will not be provided, the former order
62
- of the transactions will be used.
109
+ of the transactions will be used. Transactions sharing a timestamp
110
+ keep their order in the file, the later one being the more recent.
63
111
  """
64
112
 
65
113
  def __call__(
@@ -89,19 +137,8 @@ class TemporalHoldoutSplit(SplittingStrategy):
89
137
  - DataFrame[Any]: Second partition of splitted data.
90
138
  """
91
139
  data_prep, idx_col = self._prepare_stable_data(data)
92
-
93
- # Deterministic sorting
94
- if timestamp_label in data_prep.columns:
95
- data_prep = data_prep.sort(by=[user_id_label, timestamp_label, idx_col])
96
- rank_target_col = timestamp_label
97
- else:
98
- data_prep = data_prep.sort(by=[user_id_label, idx_col])
99
- rank_target_col = idx_col
100
-
101
- # Compute the cumulative count
102
- data_with_stats = data_prep.with_columns(
103
- n_items=nw.len().over(user_id_label),
104
- rank=nw.col(rank_target_col).rank(method="ordinal").over(user_id_label),
140
+ data_with_stats = self._order_in_time(
141
+ data_prep, user_id_label, timestamp_label, idx_col
105
142
  )
106
143
 
107
144
  # Masking
@@ -110,8 +147,8 @@ class TemporalHoldoutSplit(SplittingStrategy):
110
147
 
111
148
  # Clean the output
112
149
  cols_to_drop = ["n_items", "rank", idx_col]
113
- train = data_with_stats.filter(train_mask).drop(cols_to_drop)
114
- test = data_with_stats.filter(~train_mask).drop(cols_to_drop)
150
+ train = data_with_stats.filter(train_mask).sort(idx_col).drop(cols_to_drop)
151
+ test = data_with_stats.filter(~train_mask).sort(idx_col).drop(cols_to_drop)
115
152
 
116
153
  return [(train, test)]
117
154
 
@@ -121,7 +158,8 @@ class TemporalLeaveKOutSplit(SplittingStrategy):
121
158
  """The definition of a temporal leave k out splitting strategy.
122
159
 
123
160
  In case the timestamp will not be provided, the former order
124
- of the transactions will be used.
161
+ of the transactions will be used. Transactions sharing a timestamp
162
+ keep their order in the file, the later one being the more recent.
125
163
  """
126
164
 
127
165
  def __call__(
@@ -151,33 +189,20 @@ class TemporalLeaveKOutSplit(SplittingStrategy):
151
189
  - DataFrame[Any]: Second partition of splitted data.
152
190
  """
153
191
  data_prep, idx_col = self._prepare_stable_data(data)
154
-
155
- # Deterministic sorting
156
- if timestamp_label in data.columns:
157
- data_prep = data_prep.sort(by=[user_id_label, timestamp_label, idx_col])
158
- rank_target_col = timestamp_label
159
- else:
160
- data_prep = data_prep.sort(by=[user_id_label, idx_col])
161
- rank_target_col = idx_col
192
+ data_prep = self._order_in_time(
193
+ data_prep, user_id_label, timestamp_label, idx_col
194
+ )
162
195
 
163
196
  # Pre-filtering
164
- data_prep = data_prep.with_columns(n_items=nw.len().over(user_id_label))
165
197
  data_prep = data_prep.filter(nw.col("n_items") > k)
166
198
 
167
- # Descending sorting
168
- data_prep = data_prep.with_columns(
169
- rank_desc=nw.col(rank_target_col)
170
- .rank(method="ordinal", descending=True)
171
- .over(user_id_label)
172
- )
173
-
174
- # Masking
175
- test_mask = nw.col("rank_desc") <= k
199
+ # Masking: the last k rows of each user in temporal order
200
+ test_mask = nw.col("rank") > nw.col("n_items") - k
176
201
 
177
202
  # Clean the output
178
- cols_to_drop = ["n_items", "rank_desc", idx_col]
179
- train = data_prep.filter(~test_mask).drop(cols_to_drop)
180
- test = data_prep.filter(test_mask).drop(cols_to_drop)
203
+ cols_to_drop = ["n_items", "rank", idx_col]
204
+ train = data_prep.filter(~test_mask).sort(idx_col).drop(cols_to_drop)
205
+ test = data_prep.filter(test_mask).sort(idx_col).drop(cols_to_drop)
181
206
 
182
207
  return [(train, test)]
183
208
 
@@ -233,11 +258,13 @@ class TimestampSlicingSplit(SplittingStrategy):
233
258
  data_prep, idx_col = self._prepare_stable_data(data)
234
259
 
235
260
  if timestamp == "best":
236
- # Deterministic sorting
237
- data_prep = data_prep.sort(by=[user_id_label, timestamp_label, idx_col])
238
-
239
- # Find the best timestamp
240
- best_timestamp = self._best_split(data_prep, user_id_label, timestamp_label)
261
+ # Find the best timestamp, on a copy sorted by user and time: the
262
+ # halves themselves keep the order of the input
263
+ best_timestamp = self._best_split(
264
+ data_prep.sort(by=[user_id_label, timestamp_label, idx_col]),
265
+ user_id_label,
266
+ timestamp_label,
267
+ )
241
268
 
242
269
  # Clean the output
243
270
  data_prep = data_prep.drop(idx_col)
@@ -383,8 +410,16 @@ class RandomHoldoutSplit(SplittingStrategy):
383
410
 
384
411
  # Clean the output
385
412
  cols_to_drop = ["rand_col", "__pos_idx__", idx_col]
386
- train = data_rand.filter(nw.col("__pos_idx__") < split_idx).drop(cols_to_drop)
387
- test = data_rand.filter(nw.col("__pos_idx__") >= split_idx).drop(cols_to_drop)
413
+ train = (
414
+ data_rand.filter(nw.col("__pos_idx__") < split_idx)
415
+ .sort(idx_col)
416
+ .drop(cols_to_drop)
417
+ )
418
+ test = (
419
+ data_rand.filter(nw.col("__pos_idx__") >= split_idx)
420
+ .sort(idx_col)
421
+ .drop(cols_to_drop)
422
+ )
388
423
 
389
424
  return [(train, test)]
390
425
 
@@ -453,8 +488,8 @@ class RandomLeaveKOutSplit(SplittingStrategy):
453
488
 
454
489
  # Clean the output
455
490
  cols_to_drop = ["n_items", "rand_col", "rnd_rank", idx_col]
456
- train = data_prep.filter(~test_mask).drop(cols_to_drop)
457
- test = data_prep.filter(test_mask).drop(cols_to_drop)
491
+ train = data_prep.filter(~test_mask).sort(idx_col).drop(cols_to_drop)
492
+ test = data_prep.filter(test_mask).sort(idx_col).drop(cols_to_drop)
458
493
 
459
494
  return [(train, test)]
460
495
 
@@ -1,7 +1,7 @@
1
1
  import json
2
2
  from typing import Dict, Optional, List, Any, Generator
3
3
  from abc import ABC, abstractmethod
4
- from datetime import datetime, timedelta
4
+ from datetime import datetime
5
5
  from io import StringIO, BytesIO
6
6
  from pathlib import Path
7
7
 
@@ -35,6 +35,29 @@ from warprec.utils.enums import WritingMethods
35
35
  from warprec.utils.logger import logger
36
36
 
37
37
 
38
+ def _durations_in_seconds(report: pd.DataFrame) -> pd.DataFrame:
39
+ """Reads the h:mm:ss durations of an older time report as seconds.
40
+
41
+ Up to version 2.2.2 the durations without a unit in their name were
42
+ written as h:mm:ss (e.g. '0:01:15.5'); they are now numbers of seconds.
43
+
44
+ Args:
45
+ report (pd.DataFrame): The time report as read from its file.
46
+
47
+ Returns:
48
+ pd.DataFrame: The report, every such duration in seconds.
49
+ """
50
+ for col in report.select_dtypes(include=["object", "string"]).columns:
51
+ if col == "Model Name":
52
+ continue
53
+ values = report[col].dropna()
54
+ seconds = pd.to_timedelta(values.astype(str), errors="coerce")
55
+ if values.empty or seconds.isna().any():
56
+ continue
57
+ report[col] = pd.to_timedelta(report[col], errors="coerce").dt.total_seconds()
58
+ return report
59
+
60
+
38
61
  class Writer(ABC):
39
62
  """Writer is the base definition of a writer that centralizes processing logic
40
63
  and delegates I/O operations to subclasses.
@@ -554,7 +577,18 @@ class Writer(ABC):
554
577
  def write_time_report(
555
578
  self, time_report: List[Dict[str, Any]], sep: str = "\t", ext: str = ".tsv"
556
579
  ):
557
- """Writes the time report, handling merging with existing data."""
580
+ """Writes the time report, handling merging with existing data.
581
+
582
+ Every value is written as a number. A duration is in seconds, unless
583
+ its column names another unit. A report written by an older version,
584
+ which gave the durations as h:mm:ss, is read back in seconds.
585
+
586
+ Args:
587
+ time_report (List[Dict[str, Any]]): One row per model, its
588
+ durations in seconds and 'Inference Time' in seconds.
589
+ sep (str): The separator of the file.
590
+ ext (str): The extension of the file.
591
+ """
558
592
  path = self._path_join(
559
593
  self.experiment_evaluation_path,
560
594
  f"Time_Report_{self._timestamp}{ext}",
@@ -564,23 +598,20 @@ class Writer(ABC):
564
598
  existing_df = pd.DataFrame()
565
599
  if existing_content:
566
600
  try:
567
- existing_df = pd.read_csv(StringIO(existing_content), sep=sep)
601
+ existing_df = _durations_in_seconds(
602
+ pd.read_csv(StringIO(existing_content), sep=sep)
603
+ )
568
604
  except (pd.errors.ParserError, ValueError, pd.errors.EmptyDataError) as e:
569
605
  logger.attention(
570
606
  f"Could not parse existing time report from {path}: {e}. Overwriting."
571
607
  )
572
608
 
609
+ # Every value is a plain number: a duration in seconds unless its
610
+ # column names another unit, like 'Inference Time (ms)'
573
611
  new_df = pd.DataFrame(time_report)
574
- new_df["Inference Time (ms)"] = (new_df.pop("Inference Time") * 1000).round(6)
612
+ new_df["Inference Time (ms)"] = new_df.pop("Inference Time") * 1000
575
613
  for col in new_df.select_dtypes(include=["float"]).columns:
576
- # A column whose name gives its unit holds a number in that unit;
577
- # only the unlabelled durations are written as h:mm:ss.
578
- if col.endswith(("(MB)", "(ms)", "(s)")):
579
- new_df[col] = new_df[col].round(6)
580
- else:
581
- new_df[col] = new_df[col].apply(
582
- lambda s: str(timedelta(seconds=s)) if pd.notna(s) else np.nan
583
- )
614
+ new_df[col] = new_df[col].round(6)
584
615
 
585
616
  merge_keys = ["Model Name"]
586
617
  combined_df = pd.concat([existing_df, new_df], ignore_index=True)
@@ -1,6 +1,7 @@
1
1
  import time
2
+ from contextlib import AbstractContextManager, nullcontext
2
3
  from dataclasses import dataclass
3
- from typing import Any, Dict, List, Optional, Tuple
4
+ from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple
4
5
 
5
6
  import ray
6
7
 
@@ -31,6 +32,10 @@ from warprec.pipelines.remotes import remote_data_preparation
31
32
  from warprec.utils.enums import ResumeMode
32
33
  from warprec.utils.logger import logger
33
34
 
35
+ if TYPE_CHECKING:
36
+ # The dashboard extra is optional
37
+ from warprec.recommenders.trainer.emissions import EmissionsSettings
38
+
34
39
 
35
40
  @dataclass
36
41
  class PipelineContext:
@@ -205,6 +210,98 @@ def bootstrap_pipeline(path: str, pipeline: str, start_message: str) -> Pipeline
205
210
  )
206
211
 
207
212
 
213
+ def data_preparation_seconds(
214
+ started_at: float, emissions: Optional["EmissionsSettings"]
215
+ ) -> float:
216
+ """How long a run took to prepare its data, up to now.
217
+
218
+ The run waits for its CodeCarbon trackers to measure before it prepares the
219
+ data; that wait is not part of the preparation and is left out.
220
+
221
+ Args:
222
+ started_at (float): When the run started, as 'time.time()'.
223
+ emissions (Optional[EmissionsSettings]): The run's CodeCarbon
224
+ measurement, or None when the run is not measured.
225
+
226
+ Returns:
227
+ float: The seconds since the run started, without the wait.
228
+ """
229
+ waited = emissions.startup_seconds if emissions is not None else 0.0
230
+ return time.time() - started_at - waited
231
+
232
+
233
+ def model_timing_row( # pylint: disable = too-many-arguments
234
+ model_name: str,
235
+ data_preparation_time: float,
236
+ exploration_time: float,
237
+ ray_report: Dict[str, Any],
238
+ evaluation_time: float,
239
+ inference_time: float,
240
+ ) -> Dict[str, Any]:
241
+ """The row of the time report for one model, as train and swarm write it.
242
+
243
+ Args:
244
+ model_name (str): The name of the model.
245
+ data_preparation_time (float): The seconds the run took to prepare its
246
+ data, shared by every model.
247
+ exploration_time (float): The wall clock of the model's search, from
248
+ building its trainer to loading its best model (and, under
249
+ cross-validation, retraining it), Ray's scheduling included.
250
+ ray_report (Dict[str, Any]): The summary of the search: memory,
251
+ parameters and where the trials' time went.
252
+ evaluation_time (float): The seconds the evaluation of the best model
253
+ on the test set took on its worker.
254
+ inference_time (float): The seconds of one prediction call, which
255
+ the writer gives in milliseconds.
256
+
257
+ Returns:
258
+ Dict[str, Any]: The row, by column.
259
+ """
260
+ return {
261
+ "Model Name": model_name,
262
+ "Data Preparation Time": data_preparation_time,
263
+ "Hyperparameter Exploration Time": exploration_time,
264
+ **ray_report,
265
+ "Evaluation Time": evaluation_time,
266
+ "Inference Time": inference_time,
267
+ "Total Time": data_preparation_time + exploration_time + evaluation_time,
268
+ }
269
+
270
+
271
+ def measure_emissions(context: PipelineContext) -> AbstractContextManager[Any]:
272
+ """The CodeCarbon measurement of a run, when the configuration asks for one.
273
+
274
+ Entered as the run starts its work, before the data is prepared, and left
275
+ when it ends, whether it completes, pauses or fails, so that the data
276
+ preparation, the searches, the retraining and the test evaluation are all
277
+ covered.
278
+
279
+ Args:
280
+ context (PipelineContext): The context produced by the bootstrap.
281
+
282
+ Returns:
283
+ AbstractContextManager[Any]: An 'EmissionsRecorder', which gives the
284
+ 'EmissionsSettings' the trainers take, or a context giving None
285
+ when CodeCarbon is disabled or not installed.
286
+ """
287
+ codecarbon = context.config.dashboard.codecarbon
288
+ if not codecarbon.enabled:
289
+ return nullcontext()
290
+ try:
291
+ # pylint: disable = import-outside-toplevel # the dashboard extra is optional
292
+ from warprec.recommenders.trainer.emissions import EmissionsRecorder
293
+ except ImportError:
294
+ # The trainers say the dashboards are not available
295
+ return nullcontext()
296
+ return EmissionsRecorder(
297
+ tracking_mode=codecarbon.tracking_mode,
298
+ save_to_api=codecarbon.save_to_api,
299
+ save_to_file=codecarbon.save_to_file,
300
+ output_dir=context.config.get_storage_path(),
301
+ project_name=context.run_name,
302
+ )
303
+
304
+
208
305
  def prepare_datasets(
209
306
  context: PipelineContext,
210
307
  ) -> Tuple[Dataset, Optional[Dataset], Optional[List[Dataset]]]:
@@ -196,7 +196,15 @@ class EstimateStageTracker:
196
196
 
197
197
 
198
198
  class EstimateTrainingCallback(L.Callback):
199
- """Collects training batch timings and resource samples from Lightning."""
199
+ """Collects training batch timings and resource samples from Lightning.
200
+
201
+ A batch's time runs from the end of the batch before it (from the start
202
+ of the epoch for the first) to its own end, so it includes fetching the
203
+ batch from the loader: sampling negatives, collating, waiting for the
204
+ loader's workers. A real epoch spends that time too, and the time
205
+ report's train-only time includes it. The first 'warmup_batches' batches
206
+ are run but not measured.
207
+ """
200
208
 
201
209
  def __init__(
202
210
  self,
@@ -210,23 +218,26 @@ class EstimateTrainingCallback(L.Callback):
210
218
  self._measured_batches = measured_batches
211
219
  self._tracker = tracker
212
220
  self._device = device
213
- self._current_start: Optional[float] = None
221
+ self._previous_end: Optional[float] = None
214
222
  self._seen_batches = 0
215
223
  self.batch_times: List[float] = []
216
224
 
217
225
  def on_fit_start(self, trainer, pl_module) -> None:
218
226
  self._tracker.start()
219
227
 
228
+ def on_train_epoch_start(self, trainer, pl_module) -> None:
229
+ _sync_cuda(self._device)
230
+ self._previous_end = time.perf_counter()
231
+
220
232
  def on_train_batch_start(self, trainer, pl_module, batch, batch_idx) -> None:
221
233
  self._tracker.sample()
222
- _sync_cuda(self._device)
223
- self._current_start = time.perf_counter()
224
234
 
225
235
  def on_train_batch_end(self, trainer, pl_module, outputs, batch, batch_idx) -> None:
226
236
  _sync_cuda(self._device)
237
+ end = time.perf_counter()
227
238
  elapsed = 0.0
228
- if self._current_start is not None:
229
- elapsed = time.perf_counter() - self._current_start
239
+ if self._previous_end is not None:
240
+ elapsed = end - self._previous_end
230
241
 
231
242
  if self._seen_batches >= self._warmup_batches:
232
243
  if len(self.batch_times) < self._measured_batches:
@@ -234,6 +245,8 @@ class EstimateTrainingCallback(L.Callback):
234
245
 
235
246
  self._seen_batches += 1
236
247
  self._tracker.sample()
248
+ # The next batch is fetched from here on: its time starts now
249
+ self._previous_end = time.perf_counter()
237
250
 
238
251
 
239
252
  def _model_device(config: EstimateConfiguration, setup: dict) -> str: