shadowcollecter commited on
Commit
904ca52
·
verified ·
1 Parent(s): edaeca4

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +46 -0
  2. alibaba_ifashion/ifashion_outfit_session_v1.tsv +3 -0
  3. alibaba_ifashion/ifashion_outfit_session_v1_remapped.txt +3 -0
  4. alibaba_ifashion/ifashion_user_session.hg +3 -0
  5. alibaba_ifashion/ifashion_user_session.tsv +3 -0
  6. alibaba_ifashion/ifashion_user_session_remapped.txt +3 -0
  7. amazon_Home_and_Kitchen/maxembed_original/amazon_Home_and_Kitchen_partition.bin +3 -0
  8. amazon_Home_and_Kitchen/maxembed_paper_scale/amazon_Home_and_Kitchen.bin +3 -0
  9. amazon_Home_and_Kitchen/maxembed_paper_scale/amazon_Home_and_Kitchen_mapping.bin +3 -0
  10. amazon_Home_and_Kitchen/maxembed_paper_scale/amazon_Home_and_Kitchen_replicated_r0.1.bin +3 -0
  11. amazon_Home_and_Kitchen/maxembed_paper_scale/amazon_Home_and_Kitchen_replicated_r0.2.bin +3 -0
  12. amazon_Home_and_Kitchen/maxembed_paper_scale/amazon_Home_and_Kitchen_replicated_r0.4.bin +3 -0
  13. amazon_Home_and_Kitchen/maxembed_paper_scale/amazon_Home_and_Kitchen_replicated_r0.8.bin +3 -0
  14. amazon_Home_and_Kitchen/maxembed_paper_scale/amazon_Home_and_Kitchen_replicated_r0.bin +3 -0
  15. amazon_Home_and_Kitchen/merci_filtered/amazon_Home_and_Kitchen_test_filtered.txt +3 -0
  16. amazon_Home_and_Kitchen/merci_filtered/amazon_Home_and_Kitchen_train_filtered.txt +3 -0
  17. amazon_Office_Products/maxembed_original/amazon_Office_Products_partition.bin +3 -0
  18. amazon_Office_Products/maxembed_paper_scale/amazon_Office_Products.bin +3 -0
  19. amazon_Office_Products/maxembed_paper_scale/amazon_Office_Products_mapping.bin +3 -0
  20. amazon_Office_Products/maxembed_paper_scale/amazon_Office_Products_replicated_r0.1.bin +3 -0
  21. amazon_Office_Products/maxembed_paper_scale/amazon_Office_Products_replicated_r0.2.bin +3 -0
  22. amazon_Office_Products/maxembed_paper_scale/amazon_Office_Products_replicated_r0.4.bin +3 -0
  23. amazon_Office_Products/maxembed_paper_scale/amazon_Office_Products_replicated_r0.8.bin +3 -0
  24. amazon_Office_Products/maxembed_paper_scale/amazon_Office_Products_replicated_r0.bin +3 -0
  25. amazon_full/amazon_full_session.tsv +3 -0
  26. amazon_m2/amazon_m2_session.tsv +3 -0
  27. amazon_m2/amazon_m2_session_remapped.txt +3 -0
  28. amazon_m2/cylon_remaps/sequential_remap.json +3 -0
  29. anime/anime_session.tsv +3 -0
  30. anime/anime_session_remapped.txt +3 -0
  31. avazu/cylon_remaps/maxembed_remap.json +0 -0
  32. avazu/cylon_remaps/seedexpand_remap.json +0 -0
  33. avazu/cylon_remaps/sequential_remap.json +0 -0
  34. avazu/maxembed_paper_scale/avazu_paper_scale.py +284 -0
  35. avazu/maxembed_paper_scale/shift_ids.py +64 -0
  36. avazu/remaps_vm_copy/avz_se_remap.json +0 -0
  37. bookcrossing/bookcrossing_session.tsv +3 -0
  38. criteo_terabyte/maxembed_original/criteo_terabyte_partition.bin +3 -0
  39. criteo_terabyte/maxembed_original/criteo_terabyte_remap.txt +3 -0
  40. criteo_terabyte/merci_filtered/criteo_terabyte_train_filtered.txt +3 -0
  41. foursquare/maxembed_paper_scale/foursquare.bin +3 -0
  42. foursquare/maxembed_paper_scale/foursquare_mapping.bin +3 -0
  43. foursquare/maxembed_paper_scale/foursquare_replicated_r0.1.bin +3 -0
  44. foursquare/maxembed_paper_scale/foursquare_replicated_r0.2.bin +3 -0
  45. foursquare/maxembed_paper_scale/foursquare_replicated_r0.4.bin +3 -0
  46. foursquare/maxembed_paper_scale/foursquare_replicated_r0.8.bin +3 -0
  47. foursquare/maxembed_paper_scale/foursquare_replicated_r0.bin +3 -0
  48. gowalla/gowalla_item_mapping.tsv +3 -0
  49. gowalla/gowalla_session.tsv +3 -0
  50. gowalla/gowalla_session_remapped.txt +3 -0
.gitattributes CHANGED
@@ -58,3 +58,49 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  # Video files - compressed
59
  *.mp4 filter=lfs diff=lfs merge=lfs -text
60
  *.webm filter=lfs diff=lfs merge=lfs -text
61
+ tmall/tmall_session.tsv filter=lfs diff=lfs merge=lfs -text
62
+ tmall/tmall_session_remapped.txt filter=lfs diff=lfs merge=lfs -text
63
+ amazon_m2/amazon_m2_session_remapped.txt filter=lfs diff=lfs merge=lfs -text
64
+ amazon_m2/amazon_m2_session.tsv filter=lfs diff=lfs merge=lfs -text
65
+ movielens_10m/movielens_10m_session_remapped.txt filter=lfs diff=lfs merge=lfs -text
66
+ movielens_10m/movielens_10m_session.tsv filter=lfs diff=lfs merge=lfs -text
67
+ lastfm_360k/lastfm_360k_session_remapped.txt filter=lfs diff=lfs merge=lfs -text
68
+ amazon_full/amazon_full_session.tsv filter=lfs diff=lfs merge=lfs -text
69
+ bookcrossing/bookcrossing_session.tsv filter=lfs diff=lfs merge=lfs -text
70
+ yelp/yelp_session_remapped.txt filter=lfs diff=lfs merge=lfs -text
71
+ yelp/yelp_session.tsv filter=lfs diff=lfs merge=lfs -text
72
+ anime/anime_session.tsv filter=lfs diff=lfs merge=lfs -text
73
+ anime/anime_session_remapped.txt filter=lfs diff=lfs merge=lfs -text
74
+ alibaba_ifashion/ifashion_outfit_session_v1.tsv filter=lfs diff=lfs merge=lfs -text
75
+ alibaba_ifashion/ifashion_outfit_session_v1_remapped.txt filter=lfs diff=lfs merge=lfs -text
76
+ alibaba_ifashion/ifashion_user_session.hg filter=lfs diff=lfs merge=lfs -text
77
+ alibaba_ifashion/ifashion_user_session.tsv filter=lfs diff=lfs merge=lfs -text
78
+ alibaba_ifashion/ifashion_user_session_remapped.txt filter=lfs diff=lfs merge=lfs -text
79
+ jd/jd_session_remapped.txt filter=lfs diff=lfs merge=lfs -text
80
+ jd/jd_session.tsv filter=lfs diff=lfs merge=lfs -text
81
+ lastfm_1k/lastfm_1k_session_remapped.txt filter=lfs diff=lfs merge=lfs -text
82
+ movielens_25m/movielens_25m_session.tsv filter=lfs diff=lfs merge=lfs -text
83
+ gowalla/gowalla_session_remapped.txt filter=lfs diff=lfs merge=lfs -text
84
+ lastfm_1k/lastfm_1k_session_mapping.txt filter=lfs diff=lfs merge=lfs -text
85
+ lastfm_1k/lastfm_1k_session.tsv filter=lfs diff=lfs merge=lfs -text
86
+ gowalla/gowalla_item_mapping.tsv filter=lfs diff=lfs merge=lfs -text
87
+ gowalla/gowalla_session.tsv filter=lfs diff=lfs merge=lfs -text
88
+ movielens_25m/movielens_25m_session_remapped.txt filter=lfs diff=lfs merge=lfs -text
89
+ yoochoose/yoochoose_session_remapped.txt filter=lfs diff=lfs merge=lfs -text
90
+ million_song/million_song_session.tsv filter=lfs diff=lfs merge=lfs -text
91
+ lastfm_360k/lastfm_360k_session.tsv filter=lfs diff=lfs merge=lfs -text
92
+ yoochoose/yoochoose_session.tsv filter=lfs diff=lfs merge=lfs -text
93
+ mind/mind_session.tsv filter=lfs diff=lfs merge=lfs -text
94
+ mind/mind_session_remapped.txt filter=lfs diff=lfs merge=lfs -text
95
+ criteo_terabyte/maxembed_original/criteo_terabyte_remap.txt filter=lfs diff=lfs merge=lfs -text
96
+ movielens_32m/movielens_32m_session.tsv filter=lfs diff=lfs merge=lfs -text
97
+ tmall/cylon_remaps/sequential_remap.json filter=lfs diff=lfs merge=lfs -text
98
+ tmall/cylon_remaps/seedexpand_remap.json filter=lfs diff=lfs merge=lfs -text
99
+ movielens_32m/movielens_32m_session_remapped.txt filter=lfs diff=lfs merge=lfs -text
100
+ tmall/cylon_remaps/maxembed_remap.json filter=lfs diff=lfs merge=lfs -text
101
+ netflix/netflix_session.tsv filter=lfs diff=lfs merge=lfs -text
102
+ netflix/netflix_session_remapped.txt filter=lfs diff=lfs merge=lfs -text
103
+ criteo_terabyte/merci_filtered/criteo_terabyte_train_filtered.txt filter=lfs diff=lfs merge=lfs -text
104
+ amazon_Home_and_Kitchen/merci_filtered/amazon_Home_and_Kitchen_test_filtered.txt filter=lfs diff=lfs merge=lfs -text
105
+ amazon_Home_and_Kitchen/merci_filtered/amazon_Home_and_Kitchen_train_filtered.txt filter=lfs diff=lfs merge=lfs -text
106
+ amazon_m2/cylon_remaps/sequential_remap.json filter=lfs diff=lfs merge=lfs -text
alibaba_ifashion/ifashion_outfit_session_v1.tsv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b935aa99b6af583ea4fab1e0a7b93e65908a7f07ae238b38f62c1c1a2309f768
3
+ size 117937038
alibaba_ifashion/ifashion_outfit_session_v1_remapped.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:271c46fc85ce03739eab802ec899da624e5f1d0b270fb1fad8c9bd66e790e30c
3
+ size 24184832
alibaba_ifashion/ifashion_user_session.hg ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a3c8358e40cdbd2da64267ae2e0b5438c45b59e2d7498ca2c2845bfacb93e36e
3
+ size 179159066
alibaba_ifashion/ifashion_user_session.tsv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:73a82ff8ac765dcdb61b586c04e365cf5e47940f4cb2de8f8fbdebd8a41b47a7
3
+ size 789923298
alibaba_ifashion/ifashion_user_session_remapped.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:abd06b07cdc1a54dc9f7290fa4f3832a018150424a03fb86a932b754f205eddc
3
+ size 179159040
amazon_Home_and_Kitchen/maxembed_original/amazon_Home_and_Kitchen_partition.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:185f7f393253d68e4680847f716e44b08f446b756e326375dacb3a8661595a29
3
+ size 2772112
amazon_Home_and_Kitchen/maxembed_paper_scale/amazon_Home_and_Kitchen.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fc3c0c0ad22292f5cf2436250c522630849fbe93c3e00b0756e270fe990bbead
3
+ size 38447204
amazon_Home_and_Kitchen/maxembed_paper_scale/amazon_Home_and_Kitchen_mapping.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c0f8c270442030e52867b6c96eb1b433ad362ab3df8b5dae81b9f71edfcd52de
3
+ size 2772112
amazon_Home_and_Kitchen/maxembed_paper_scale/amazon_Home_and_Kitchen_replicated_r0.1.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e7b3f608efade143199b819fdcdee09b60b826b51c36ccf3be5fd083b24fee56
3
+ size 2864528
amazon_Home_and_Kitchen/maxembed_paper_scale/amazon_Home_and_Kitchen_replicated_r0.2.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2f233342c0fcc16c6fd5ebcf2844faa237de6514e1299d82da2aaa8a5d3c67ab
3
+ size 2956944
amazon_Home_and_Kitchen/maxembed_paper_scale/amazon_Home_and_Kitchen_replicated_r0.4.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8a8c0e6e0cb8bca2eb4299e54f8e6b636d583ce70eb522da4186cb5bfd3888b6
3
+ size 3141776
amazon_Home_and_Kitchen/maxembed_paper_scale/amazon_Home_and_Kitchen_replicated_r0.8.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e1f36286feb791704206f8a0f07093b2165c206d5acc09156dd81ace0ba27dc2
3
+ size 3511376
amazon_Home_and_Kitchen/maxembed_paper_scale/amazon_Home_and_Kitchen_replicated_r0.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c0f8c270442030e52867b6c96eb1b433ad362ab3df8b5dae81b9f71edfcd52de
3
+ size 2772112
amazon_Home_and_Kitchen/merci_filtered/amazon_Home_and_Kitchen_test_filtered.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ec7e75446e111feb6f0f0251e7c896075b93b53b77221bc28198d475f573d687
3
+ size 11170482
amazon_Home_and_Kitchen/merci_filtered/amazon_Home_and_Kitchen_train_filtered.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e76b62698d76c609f41fc9e17fe392a0353ef4f75fd7784833f48b1c8b05585d
3
+ size 12568206
amazon_Office_Products/maxembed_original/amazon_Office_Products_partition.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:19e837e8e980355a2c6f6e3fd7f3178538ec753deac845e376e7e1c24bac0d20
3
+ size 367384
amazon_Office_Products/maxembed_paper_scale/amazon_Office_Products.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b31989e748e51ea246f7c870438e05f126f6323e0153ca2f5126fc2107e8c0fa
3
+ size 2759708
amazon_Office_Products/maxembed_paper_scale/amazon_Office_Products_mapping.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d8357607d7cc2731100b75b09e87ad97be08d7f3091873641ab363944f54c644
3
+ size 367384
amazon_Office_Products/maxembed_paper_scale/amazon_Office_Products_replicated_r0.1.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:744af9e09ae625056810431164545b9334a8ac84c92b5820ccbebfd182b724bf
3
+ size 379672
amazon_Office_Products/maxembed_paper_scale/amazon_Office_Products_replicated_r0.2.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:14baac785a24332b84d8a70778e1c86df1ac16eab0aad5fb941d09dcf81db1f9
3
+ size 391896
amazon_Office_Products/maxembed_paper_scale/amazon_Office_Products_replicated_r0.4.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8196f21b1cb2afb6b6c561a7a8c9ebb99790543acf43d8183775e861fecca176
3
+ size 416408
amazon_Office_Products/maxembed_paper_scale/amazon_Office_Products_replicated_r0.8.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:13b4c6eedac13bc97a1d9f4541c3c8e3e135db5c4cf5d26f31f6967ead836685
3
+ size 465368
amazon_Office_Products/maxembed_paper_scale/amazon_Office_Products_replicated_r0.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d8357607d7cc2731100b75b09e87ad97be08d7f3091873641ab363944f54c644
3
+ size 367384
amazon_full/amazon_full_session.tsv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:775b75eeee24bf411624e6d753d98afea8a4dc3fc720eabb4632f2b340742bc1
3
+ size 18581089
amazon_m2/amazon_m2_session.tsv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f3b6f01978e6c916b4b9f4526f12de72d0ec0cc8c28b389774f13464268cf328
3
+ size 208036773
amazon_m2/amazon_m2_session_remapped.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c1ae13e42f86219a9bdee0f8e6555d12ab2f9d27547f12fee584821b7d554d88
3
+ size 136225011
amazon_m2/cylon_remaps/sequential_remap.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:168c2b845df2e71a886e3549a00dc1aa9f9d70342a74bcbdf005b8259ce68785
3
+ size 11434607
anime/anime_session.tsv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1e288dad0e28af60862beeb192c32fa5ab3a44ec0e5f02209d3f9893ba2a4024
3
+ size 39786210
anime/anime_session_remapped.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0d4ef84c6168e27e1b02dca53935165ba222d75673b0d41deb9fcfb76a84ce32
3
+ size 39244059
avazu/cylon_remaps/maxembed_remap.json ADDED
The diff for this file is too large to render. See raw diff
 
avazu/cylon_remaps/seedexpand_remap.json ADDED
The diff for this file is too large to render. See raw diff
 
avazu/cylon_remaps/sequential_remap.json ADDED
The diff for this file is too large to render. See raw diff
 
avazu/maxembed_paper_scale/avazu_paper_scale.py ADDED
@@ -0,0 +1,284 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Paper-scale Avazu hypergraph generator.
4
+
5
+ Follows MaxEmbed's official preprocess.py logic but uses efficient pandas primitives
6
+ (pd.factorize + vectorized value_counts) to scale to the full 40.4M-row Avazu dataset.
7
+
8
+ Steps replicated from MaxEmbed/partition/preprocess/avazu_script/preprocess.py:
9
+ 1. Drop 'id' column, keep everything else as strings/ints.
10
+ 2. Fill missing categorical with '80000000', missing integer with INT_MIN.
11
+ 3. For categorical cols: ordinal encode by descending frequency, +1 (min=1).
12
+ 4. For dense col (I1=hour): LabelEncoder, +1.
13
+ 5. Apply offsets: for categorical cols, df[col] += offset, offset += col.max().
14
+ 6. Drop first `drop_cnt` columns (label, I1 by default), leaving C1..C21.
15
+ 7. Per-row dedup (MaxEmbed feature: overlapping offsets make some rows short).
16
+ 8. Emit MaxEmbed hypergraph text format.
17
+
18
+ Default: drop_cnt=2, normalize_dense=0, feature_cross=0.
19
+ Input: train.csv with header row.
20
+ Output: <prefix>_hypergraph.txt
21
+ """
22
+
23
+ import argparse
24
+ import logging
25
+ import numpy as np
26
+ import pandas as pd
27
+ import sklearn.preprocessing as skp
28
+ import time
29
+ import os
30
+
31
+ logging.basicConfig(format='%(asctime)s %(message)s', level=logging.INFO)
32
+ log = logging.info
33
+
34
+ NUM_INTEGER_COLUMNS = 1
35
+ NUM_CATEGORICAL_COLUMNS = 21
36
+ # Column names aligned with MaxEmbed script:
37
+ # label = click, I1 = hour, C1..C21 = remaining 21 categorical columns
38
+ # Source CSV cols (post-drop-id): click, hour, C1, banner_pos, site_id, site_domain,
39
+ # site_category, app_id, app_domain, app_category, device_id, device_ip, device_model,
40
+ # device_type, device_conn_type, C14, C15, C16, C17, C18, C19, C20, C21
41
+ SCRIPT_COLS = ['label', 'I1'] + [f'C{i}' for i in range(1, NUM_CATEGORICAL_COLUMNS + 1)]
42
+ CAT_COLS = SCRIPT_COLS[2:] # C1..C21
43
+ DENSE_COLS = ['I1']
44
+ LABEL_COL = 'label'
45
+ CAT_NAN_VALUE = '80000000'
46
+ INT_NAN_VALUE = np.iinfo(np.int32).min
47
+
48
+
49
+ def main():
50
+ ap = argparse.ArgumentParser()
51
+ ap.add_argument('--src_csv_path', required=True)
52
+ ap.add_argument('--output_prefix', required=True,
53
+ help='Output prefix. Writes <prefix>_hypergraph.txt (+ optional .bin).')
54
+ ap.add_argument('--drop_cnt', type=int, default=2,
55
+ help='Leading columns to drop (0=keep label+I1+C*, 2=drop label+I1).')
56
+ ap.add_argument('--normalize_dense', type=int, default=0,
57
+ help='If 1, MinMax-scale I1 to [0,1]. Default 0 so values stay integer.')
58
+ ap.add_argument('--binary', type=int, default=1,
59
+ help='Also write binary trans_query format .bin file.')
60
+ ap.add_argument('--dedup_per_row', type=int, default=1,
61
+ help='Deduplicate overlapping vertex IDs within each query (MaxEmbed style).')
62
+ args = ap.parse_args()
63
+
64
+ t0 = time.time()
65
+ log(f'Reading CSV from {args.src_csv_path}')
66
+ # Read full CSV, skip header, assign SCRIPT_COLS names.
67
+ # First column in source is 'id' which we skip via usecols.
68
+ src_cols_total = 1 + 1 + 1 + NUM_CATEGORICAL_COLUMNS # id + label + I1 + 21 cats
69
+ usecols = list(range(1, src_cols_total)) # skip id (col 0)
70
+
71
+ # Use category-aware dtypes during read for memory:
72
+ # label + I1 = int32 (after fillna), cats = string (factorize later).
73
+ dtype_map = {}
74
+ for i, c in enumerate(SCRIPT_COLS):
75
+ dtype_map[c] = 'string' # read as string first, cast later
76
+
77
+ df = pd.read_csv(args.src_csv_path,
78
+ header=0,
79
+ names=SCRIPT_COLS,
80
+ usecols=usecols,
81
+ dtype=dtype_map,
82
+ engine='c',
83
+ low_memory=True)
84
+ log(f'CSV loaded: shape={df.shape} in {time.time()-t0:.1f}s')
85
+
86
+ # ---- Fill missing ----
87
+ log('Filling missing values')
88
+ for c in CAT_COLS:
89
+ df[c] = df[c].fillna(CAT_NAN_VALUE)
90
+ # label and I1 are numeric. Fill with INT_NAN then cast.
91
+ df[LABEL_COL] = df[LABEL_COL].fillna(str(INT_NAN_VALUE)).astype(np.int64)
92
+ df['I1'] = df['I1'].fillna(str(INT_NAN_VALUE)).astype(np.int64)
93
+
94
+ # ---- Transform per column ----
95
+ # Label and dense: LabelEncoder (fit+transform). Same as script: codes + 1 for dense (not label).
96
+ log('Encoding label via LabelEncoder')
97
+ le = skp.LabelEncoder()
98
+ df[LABEL_COL] = le.fit_transform(df[LABEL_COL].values).astype(np.int64)
99
+
100
+ log('Encoding I1 via LabelEncoder, +1')
101
+ le = skp.LabelEncoder()
102
+ df['I1'] = le.fit_transform(df['I1'].values).astype(np.int64) + 1
103
+
104
+ # We apply `+1` to match the official script so that 0 can be reserved, but
105
+ # later we must produce 0-indexed IDs to satisfy MaxEmbed's `num < c` invariant.
106
+ # We compensate by subtracting 1 at the final write stage.
107
+
108
+ if args.normalize_dense:
109
+ mms = skp.MinMaxScaler(feature_range=(0, 1))
110
+ df['I1'] = mms.fit_transform(df[['I1']].values).ravel()
111
+ # Note: normalizing integer IDs is weird; we leave this for compat.
112
+
113
+ # Categorical: ordinal encode by descending frequency, +1
114
+ # Original script uses value_counts() and applies .index.get_loc() per row (O(N*K)).
115
+ # Equivalent & fast: pd.factorize then remap codes by frequency rank.
116
+ for c in CAT_COLS:
117
+ tt = time.time()
118
+ codes, uniques = pd.factorize(df[c], sort=False)
119
+ # Frequency of each code
120
+ counts = np.bincount(codes.astype(np.int64, copy=False))
121
+ # Order descending by count. argsort on descending gives the new rank.
122
+ # rank[old_code] = new_code (0..K-1 by desc freq)
123
+ order = np.argsort(-counts, kind='stable')
124
+ new_rank = np.empty_like(order)
125
+ new_rank[order] = np.arange(len(order))
126
+ df[c] = (new_rank[codes] + 1).astype(np.int64) # +1 so min=1
127
+ log(f' col {c}: unique={len(uniques):>10,} in {time.time()-tt:.1f}s')
128
+
129
+ # ---- Min/max per column ----
130
+ # Matches original script's min_max collection (used for offset bookkeeping).
131
+ min_max = {}
132
+ for c in SCRIPT_COLS:
133
+ if c == LABEL_COL or c.startswith('I'):
134
+ mn = int(df[c].min()); mx = int(df[c].max())
135
+ min_max[c] = (mn, mx)
136
+ else:
137
+ mn = int(df[c].min()); mx = int(df[c].max())
138
+ min_max[c] = (mn, mx)
139
+ log(f' min_max[{c}] = [{min_max[c][0]}, {min_max[c][1]}]')
140
+
141
+ # ---- Apply offsets to categorical columns ----
142
+ log('Applying column offsets')
143
+ offset = np.int64(0)
144
+ for c in SCRIPT_COLS:
145
+ if c == LABEL_COL or c.startswith('I'):
146
+ continue
147
+ df[c] += offset
148
+ log(f' {c} offset={offset}')
149
+ offset += min_max[c][1]
150
+
151
+ total_vocab = int(offset)
152
+ log(f'Total offset (vocab across cat cols) = {total_vocab}')
153
+
154
+ # ---- Drop leading columns ----
155
+ cols_after_drop = SCRIPT_COLS[args.drop_cnt:]
156
+ log(f'Keeping columns: {cols_after_drop}')
157
+
158
+ # ---- Write hypergraph ----
159
+ out_txt = args.output_prefix + '_hypergraph.txt'
160
+ out_bin = args.output_prefix + '.bin'
161
+ log(f'Writing {out_txt}')
162
+
163
+ # Convert selected columns to int32 numpy for fast serialization
164
+ # (I1 can be float if normalize_dense=1; we coerce to int to fit text format unless normalized.)
165
+ kept_arrays = []
166
+ for c in cols_after_drop:
167
+ if c == 'I1' and args.normalize_dense:
168
+ kept_arrays.append(df[c].values.astype(np.float64))
169
+ else:
170
+ kept_arrays.append(df[c].values.astype(np.int64))
171
+ mat = np.column_stack(kept_arrays)
172
+ num_queries = mat.shape[0]
173
+ ncols = mat.shape[1]
174
+ log(f'Row-matrix built: {mat.shape}')
175
+
176
+ # Compute num_vertices and total_pins.
177
+ # vertices = unique global IDs across kept columns (excluding label which is a different "type"
178
+ # but original script uses drop_cnt=2 so label is dropped; if drop_cnt=0 we include label too).
179
+ # Since IDs are already offset, unique across mat.flatten() gives exact vocab.
180
+ # For efficiency with 800M+ entries, use np.unique (uses radix sort in numpy 2.x and is OK here).
181
+ log('Computing unique vertices (this may take 1-2 min)')
182
+ t1 = time.time()
183
+ all_vals = mat.ravel()
184
+ if args.dedup_per_row:
185
+ # Per-row dedup for MaxEmbed format: sort within row and drop duplicates.
186
+ # We implement this while writing to avoid huge intermediate.
187
+ # For vertex count: just use unique over all.
188
+ uniq_vertices = np.unique(all_vals)
189
+ num_vertices = uniq_vertices.size
190
+ log(f' unique vertices = {num_vertices:,} (in {time.time()-t1:.1f}s)')
191
+
192
+ # Write file streaming, with per-row dedup.
193
+ # Pass 1: compute per-row dedup'd rows into a list-of-arrays, also sum pins.
194
+ # Then write file with correct header in one pass. At 40M queries with avg 20 pins,
195
+ # storing arrays is ~3.2GB (uint32) which fits in 197GB RAM.
196
+ log('Pass 1: per-row sort + dedup + pin count')
197
+ t1 = time.time()
198
+ # We'll precompute CSR (offsets + all_data) which is also what .bin needs.
199
+ # Upper bound on total pins = num_queries * ncols.
200
+ all_data = np.empty(num_queries * ncols, dtype=np.uint32)
201
+ offsets_arr = np.zeros(num_queries + 1, dtype=np.uint64)
202
+ cursor = 0
203
+ CHUNK = 262144
204
+ for start in range(0, num_queries, CHUNK):
205
+ end = min(start + CHUNK, num_queries)
206
+ block = mat[start:end]
207
+ block_sorted = np.sort(block, axis=1)
208
+ diff = np.diff(block_sorted, axis=1, prepend=np.int64(-1))
209
+ keep = diff != 0
210
+ # Per-row write into all_data
211
+ for i in range(block_sorted.shape[0]):
212
+ row = block_sorted[i][keep[i]]
213
+ all_data[cursor:cursor+row.size] = row.astype(np.uint32, copy=False)
214
+ cursor += row.size
215
+ offsets_arr[start + i + 1] = cursor
216
+ if start % (CHUNK * 40) == 0:
217
+ log(f' rows processed {end:,}/{num_queries:,} pins={cursor:,} '
218
+ f'elapsed={time.time()-t1:.0f}s')
219
+ total_pins = cursor
220
+ # Truncate all_data
221
+ all_data = all_data[:total_pins]
222
+ log(f'Pass 1 done: total_pins={total_pins:,} in {time.time()-t1:.0f}s')
223
+
224
+ log(f'Pass 2: writing {out_txt}')
225
+ t1 = time.time()
226
+ with open(out_txt, 'w') as f:
227
+ f.write('0 {} {} {}\n'.format(num_vertices, num_queries, total_pins))
228
+ # Write rows. Use numpy savetxt-like approach per chunk for speed.
229
+ for start in range(0, num_queries, CHUNK):
230
+ end = min(start + CHUNK, num_queries)
231
+ chunk_off_start = offsets_arr[start]
232
+ chunk_off_end = offsets_arr[end]
233
+ # Build text per row
234
+ lines = []
235
+ for i in range(start, end):
236
+ r = all_data[offsets_arr[i]:offsets_arr[i+1]]
237
+ lines.append(' '.join(map(str, r.tolist())))
238
+ f.write('\n'.join(lines))
239
+ f.write('\n')
240
+ if start % (CHUNK * 40) == 0:
241
+ log(f' rows written {end:,}/{num_queries:,} elapsed={time.time()-t1:.0f}s')
242
+ log(f' wrote {out_txt} in {time.time()-t1:.0f}s')
243
+ else:
244
+ # No dedup: all rows have fixed width = ncols
245
+ total_pins = num_queries * ncols
246
+ uniq_vertices = np.unique(all_vals)
247
+ num_vertices = uniq_vertices.size
248
+ log(f' unique vertices = {num_vertices:,} total_pins = {total_pins:,}')
249
+ log('Writing hypergraph (no dedup)')
250
+ with open(out_txt, 'w') as f:
251
+ f.write('0 {} {} {}\n'.format(num_vertices, num_queries, total_pins))
252
+ CHUNK = 262144
253
+ for start in range(0, num_queries, CHUNK):
254
+ end = min(start + CHUNK, num_queries)
255
+ block = mat[start:end]
256
+ lines = ['\n'.join(' '.join(map(str, row.tolist())) for row in block)]
257
+ f.write(lines[0] + '\n')
258
+
259
+ log(f'Vocab summary: num_vertices={num_vertices:,} num_queries={num_queries:,} total_pins={total_pins:,}')
260
+ sz = os.path.getsize(out_txt)
261
+ log(f'{out_txt}: {sz/1e6:.1f} MB')
262
+
263
+ # Optional: write binary .bin format matching trans_query.cpp
264
+ if args.binary and args.dedup_per_row:
265
+ log(f'Writing binary {out_bin}')
266
+ # Format from trans_query.cpp:
267
+ # uint64 query_cnt
268
+ # uint64 node_cnt
269
+ # uint64 index[query_cnt+1] (CSR offsets into all_data)
270
+ # uint32 all_data[total_pins]
271
+ with open(out_bin, 'wb') as f:
272
+ f.write(np.uint64(num_queries).tobytes())
273
+ f.write(np.uint64(num_vertices).tobytes())
274
+ f.write(offsets_arr.tobytes())
275
+ f.write(all_data.tobytes())
276
+ log(f' wrote {out_bin} size={os.path.getsize(out_bin)/1e6:.1f} MB')
277
+ elif args.binary:
278
+ log('--binary requires --dedup_per_row=1 (no-dedup binary path not implemented)')
279
+
280
+ log(f'Done in {time.time()-t0:.0f}s')
281
+
282
+
283
+ if __name__ == '__main__':
284
+ main()
avazu/maxembed_paper_scale/shift_ids.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Shift all vertex IDs by -1 in-place for the avazu hypergraph to match
3
+ MaxEmbed's `num < c` invariant (max must be < num_vertices).
4
+
5
+ Applied to both avazu.bin (binary) and avazu_hypergraph.txt (text)."""
6
+ import numpy as np
7
+ import os
8
+ import time
9
+ import struct
10
+
11
+ txt_path = '/home/sadoo/research_data/processed/avazu/maxembed_paper_scale/avazu_hypergraph.txt'
12
+ bin_path = '/home/sadoo/research_data/processed/avazu/maxembed_paper_scale/avazu.bin'
13
+
14
+ # --- Binary: shift pins by 1 ---
15
+ t0 = time.time()
16
+ print(f'Shifting binary {bin_path}')
17
+ with open(bin_path, 'rb') as f:
18
+ query_cnt = struct.unpack('<Q', f.read(8))[0]
19
+ node_cnt = struct.unpack('<Q', f.read(8))[0]
20
+ print(f' query_cnt={query_cnt:,} node_cnt={node_cnt:,}')
21
+ offsets = np.frombuffer(f.read((query_cnt+1) * 8), dtype=np.uint64).copy()
22
+ pins = np.fromfile(f, dtype=np.uint32)
23
+ print(f' loaded pins: {len(pins):,} max={pins.max()} min={pins.min()} (elapsed {time.time()-t0:.0f}s)')
24
+ pins -= 1
25
+ print(f' after shift: max={pins.max()} min={pins.min()}')
26
+
27
+ tmp_path = bin_path + '.tmp'
28
+ with open(tmp_path, 'wb') as f:
29
+ f.write(np.uint64(query_cnt).tobytes())
30
+ f.write(np.uint64(node_cnt).tobytes())
31
+ f.write(offsets.tobytes())
32
+ pins.tofile(f)
33
+ os.rename(tmp_path, bin_path)
34
+ print(f' binary rewritten in {time.time()-t0:.0f}s, size={os.path.getsize(bin_path):,}')
35
+
36
+ # --- Text: rewrite with IDs shifted by 1 using numpy-backed CSR reconstruction ---
37
+ # We already have offsets + pins in memory (shifted), just re-emit text from them.
38
+ t0 = time.time()
39
+ print(f'Shifting text {txt_path}')
40
+ tmp_path = txt_path + '.tmp'
41
+ # Header: keep same (num_vertices was already correct = 9,449,205)
42
+ # but now vertex IDs are 0-indexed, so max=9449204 < num_vertices=9449205.
43
+ with open(tmp_path, 'w') as fout:
44
+ fout.write(f'0 {int(node_cnt)} {int(query_cnt)} {len(pins)}\n')
45
+ CHUNK = 262144
46
+ # Use buffered writes via join of per-row strings
47
+ cursor = 0
48
+ for start in range(0, int(query_cnt), CHUNK):
49
+ end = min(start + CHUNK, int(query_cnt))
50
+ # per-row slicing
51
+ buf = []
52
+ for i in range(start, end):
53
+ lo = int(offsets[i])
54
+ hi = int(offsets[i+1])
55
+ row = pins[lo:hi]
56
+ buf.append(' '.join(map(str, row.tolist())))
57
+ fout.write('\n'.join(buf))
58
+ fout.write('\n')
59
+ if start % (CHUNK * 40) == 0:
60
+ print(f' rows written {end:,}/{int(query_cnt):,} elapsed={time.time()-t0:.0f}s')
61
+ os.rename(tmp_path, txt_path)
62
+ print(f' text rewritten in {time.time()-t0:.0f}s size={os.path.getsize(txt_path):,}')
63
+
64
+ print('Done')
avazu/remaps_vm_copy/avz_se_remap.json ADDED
The diff for this file is too large to render. See raw diff
 
bookcrossing/bookcrossing_session.tsv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d267c11e42aaa07e9ae9d74f4ff34e8cfd172456079c9f4c88ed24e038a2ac78
3
+ size 11998288
criteo_terabyte/maxembed_original/criteo_terabyte_partition.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:da1b5368e0dcd427fcce8646e196dda19eaf303e5800fc45f4291a7820d03479
3
+ size 10573588
criteo_terabyte/maxembed_original/criteo_terabyte_remap.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3539a7544a6e849b4bb464a17009379eff0d10aadb53235c9f134c81f3a68c58
3
+ size 11335863
criteo_terabyte/merci_filtered/criteo_terabyte_train_filtered.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8078377cc734dc4ad724f5bc405b8f47b1626e7e264a5806d20a098fccd8a7ff
3
+ size 46032900
foursquare/maxembed_paper_scale/foursquare.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ca9c1a67406a1c63b442f85d8b554178d574d57150216a5847c33f23d98dc219
3
+ size 1230284
foursquare/maxembed_paper_scale/foursquare_mapping.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:26cc695cad773898ac6bb18ab0151580ddf4c0e58420b61b63a15ce65590ef38
3
+ size 1202308
foursquare/maxembed_paper_scale/foursquare_replicated_r0.1.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bbf6a10a23d0a0d823d2a9b3c61ccedbeca3bb107321454afd8b7dbab3a185d6
3
+ size 1242436
foursquare/maxembed_paper_scale/foursquare_replicated_r0.2.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:890b616cb374866751d362085b8d9bee6e39e89a878f60b228437268d072a69f
3
+ size 1282500
foursquare/maxembed_paper_scale/foursquare_replicated_r0.4.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e97a2d078c9582c30e14d447243b4933badf0341e5d79be9c974c4d778792ece
3
+ size 1362628
foursquare/maxembed_paper_scale/foursquare_replicated_r0.8.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2373c72d543be32e49171547df5eb2fee5882734c4154530281a4eb023eaaab9
3
+ size 1522948
foursquare/maxembed_paper_scale/foursquare_replicated_r0.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:26cc695cad773898ac6bb18ab0151580ddf4c0e58420b61b63a15ce65590ef38
3
+ size 1202308
gowalla/gowalla_item_mapping.tsv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:21508488a836c3308bf68dc473e750cdc61d2ea24902e21f76d4a44877fdc438
3
+ size 18570235
gowalla/gowalla_session.tsv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a50a89c108ff51c0e4b6f6036abf0bfc07dfefb3534827d6e7be1b3505541e35
3
+ size 27851812
gowalla/gowalla_session_remapped.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cc0673c93e826d93a6cd5e1b4c9570ee3749c1651adf77fb8252f1b78a4ead78
3
+ size 28324176