Upload folder using huggingface_hub
Browse files- README.md +181 -0
- sharechat.py +157 -0
README.md
ADDED
@@ -0,0 +1,181 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
dataset_info:
|
3 |
+
config_name: first_domain
|
4 |
+
features:
|
5 |
+
- name: f_0
|
6 |
+
dtype: int64
|
7 |
+
- name: f_1
|
8 |
+
dtype: int8
|
9 |
+
- name: f_2
|
10 |
+
dtype: int32
|
11 |
+
- name: f_3
|
12 |
+
dtype: int32
|
13 |
+
- name: f_4
|
14 |
+
dtype: int32
|
15 |
+
- name: f_5
|
16 |
+
dtype: int32
|
17 |
+
- name: f_6
|
18 |
+
dtype: int32
|
19 |
+
- name: f_7
|
20 |
+
dtype: int32
|
21 |
+
- name: f_8
|
22 |
+
dtype: int32
|
23 |
+
- name: f_9
|
24 |
+
dtype: int32
|
25 |
+
- name: f_10
|
26 |
+
dtype: int32
|
27 |
+
- name: f_11
|
28 |
+
dtype: int32
|
29 |
+
- name: f_12
|
30 |
+
dtype: int32
|
31 |
+
- name: f_13
|
32 |
+
dtype: int32
|
33 |
+
- name: f_14
|
34 |
+
dtype: int32
|
35 |
+
- name: f_15
|
36 |
+
dtype: int32
|
37 |
+
- name: f_16
|
38 |
+
dtype: int32
|
39 |
+
- name: f_17
|
40 |
+
dtype: int32
|
41 |
+
- name: f_18
|
42 |
+
dtype: int32
|
43 |
+
- name: f_19
|
44 |
+
dtype: int32
|
45 |
+
- name: f_20
|
46 |
+
dtype: int32
|
47 |
+
- name: f_21
|
48 |
+
dtype: int32
|
49 |
+
- name: f_22
|
50 |
+
dtype: int32
|
51 |
+
- name: f_23
|
52 |
+
dtype: int32
|
53 |
+
- name: f_24
|
54 |
+
dtype: int32
|
55 |
+
- name: f_25
|
56 |
+
dtype: int32
|
57 |
+
- name: f_26
|
58 |
+
dtype: int32
|
59 |
+
- name: f_27
|
60 |
+
dtype: int32
|
61 |
+
- name: f_28
|
62 |
+
dtype: int32
|
63 |
+
- name: f_29
|
64 |
+
dtype: int32
|
65 |
+
- name: f_30
|
66 |
+
dtype: int32
|
67 |
+
- name: f_31
|
68 |
+
dtype: int32
|
69 |
+
- name: f_32
|
70 |
+
dtype: int32
|
71 |
+
- name: f_33
|
72 |
+
dtype: int8
|
73 |
+
- name: f_34
|
74 |
+
dtype: int8
|
75 |
+
- name: f_35
|
76 |
+
dtype: int8
|
77 |
+
- name: f_36
|
78 |
+
dtype: int8
|
79 |
+
- name: f_37
|
80 |
+
dtype: int8
|
81 |
+
- name: f_38
|
82 |
+
dtype: int8
|
83 |
+
- name: f_39
|
84 |
+
dtype: int8
|
85 |
+
- name: f_40
|
86 |
+
dtype: int8
|
87 |
+
- name: f_41
|
88 |
+
dtype: int8
|
89 |
+
- name: f_42
|
90 |
+
dtype: float32
|
91 |
+
- name: f_43
|
92 |
+
dtype: float32
|
93 |
+
- name: f_44
|
94 |
+
dtype: float32
|
95 |
+
- name: f_45
|
96 |
+
dtype: float32
|
97 |
+
- name: f_46
|
98 |
+
dtype: float32
|
99 |
+
- name: f_47
|
100 |
+
dtype: float32
|
101 |
+
- name: f_48
|
102 |
+
dtype: float32
|
103 |
+
- name: f_49
|
104 |
+
dtype: float32
|
105 |
+
- name: f_50
|
106 |
+
dtype: float32
|
107 |
+
- name: f_51
|
108 |
+
dtype: float32
|
109 |
+
- name: f_52
|
110 |
+
dtype: float32
|
111 |
+
- name: f_53
|
112 |
+
dtype: float32
|
113 |
+
- name: f_54
|
114 |
+
dtype: float32
|
115 |
+
- name: f_55
|
116 |
+
dtype: float32
|
117 |
+
- name: f_56
|
118 |
+
dtype: float32
|
119 |
+
- name: f_57
|
120 |
+
dtype: float32
|
121 |
+
- name: f_58
|
122 |
+
dtype: float32
|
123 |
+
- name: f_59
|
124 |
+
dtype: float32
|
125 |
+
- name: f_60
|
126 |
+
dtype: float32
|
127 |
+
- name: f_61
|
128 |
+
dtype: float32
|
129 |
+
- name: f_62
|
130 |
+
dtype: float32
|
131 |
+
- name: f_63
|
132 |
+
dtype: float32
|
133 |
+
- name: f_64
|
134 |
+
dtype: float32
|
135 |
+
- name: f_65
|
136 |
+
dtype: float32
|
137 |
+
- name: f_66
|
138 |
+
dtype: float32
|
139 |
+
- name: f_67
|
140 |
+
dtype: float32
|
141 |
+
- name: f_68
|
142 |
+
dtype: float32
|
143 |
+
- name: f_69
|
144 |
+
dtype: float32
|
145 |
+
- name: f_70
|
146 |
+
dtype: float32
|
147 |
+
- name: f_71
|
148 |
+
dtype: float32
|
149 |
+
- name: f_72
|
150 |
+
dtype: float32
|
151 |
+
- name: f_73
|
152 |
+
dtype: float32
|
153 |
+
- name: f_74
|
154 |
+
dtype: float32
|
155 |
+
- name: f_75
|
156 |
+
dtype: float32
|
157 |
+
- name: f_76
|
158 |
+
dtype: float32
|
159 |
+
- name: f_77
|
160 |
+
dtype: float32
|
161 |
+
- name: f_78
|
162 |
+
dtype: float32
|
163 |
+
- name: f_79
|
164 |
+
dtype: float32
|
165 |
+
- name: is_clicked
|
166 |
+
dtype: int8
|
167 |
+
- name: is_installed
|
168 |
+
dtype: int8
|
169 |
+
splits:
|
170 |
+
- name: train
|
171 |
+
num_bytes: 964563810
|
172 |
+
num_examples: 3240869
|
173 |
+
- name: validation
|
174 |
+
num_bytes: 43754365
|
175 |
+
num_examples: 147011
|
176 |
+
- name: test
|
177 |
+
num_bytes: 29159092
|
178 |
+
num_examples: 97972
|
179 |
+
download_size: 488593303
|
180 |
+
dataset_size: 1037477267
|
181 |
+
---
|
sharechat.py
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""The dataset corresponds to roughly 10M random users who visited the ShareChat + Moj app over three months.
|
2 |
+
We have sampled each user's activity to generate 10 impressions corresponding to each user.
|
3 |
+
Our target variable is whether there was an install for an app by the user or not.
|
4 |
+
"""
|
5 |
+
|
6 |
+
|
7 |
+
import csv
|
8 |
+
import json
|
9 |
+
import os
|
10 |
+
import glob
|
11 |
+
import polars as pl
|
12 |
+
|
13 |
+
import datasets
|
14 |
+
|
15 |
+
|
16 |
+
_CITATION = """\
|
17 |
+
@incollection{agrawal2023recsys,
|
18 |
+
title={RecSys Challenge 2023 Dataset: Ads Recommendations in Online Advertising},
|
19 |
+
author={Agrawal, Rahul and Brahme, Sarang and Maitra, Sourav and Srivastava, Abhishek and Irissappane, Athirai and Liu, Yong and Kalloori, Saikishore},
|
20 |
+
booktitle={Proceedings of the Recommender Systems Challenge 2023},
|
21 |
+
pages={1--3},
|
22 |
+
year={2023}
|
23 |
+
}
|
24 |
+
"""
|
25 |
+
|
26 |
+
_DESCRIPTION = """\
|
27 |
+
The dataset corresponds to roughly 10M random users who visited the ShareChat + Moj app over three months.
|
28 |
+
We have sampled each user's activity to generate 10 impressions corresponding to each user.
|
29 |
+
Our target variable is whether there was an install for an app by the user or not.
|
30 |
+
"""
|
31 |
+
|
32 |
+
_HOMEPAGE = "https://www.recsyschallenge.com/2023/"
|
33 |
+
|
34 |
+
# TODO: Add the licence for the dataset here if you can find it
|
35 |
+
_LICENSE = ""
|
36 |
+
|
37 |
+
|
38 |
+
_URLS = {
|
39 |
+
"first_domain": "https://cdn.sharechat.com/2a161f8e_1679936280892_sc.zip",
|
40 |
+
}
|
41 |
+
|
42 |
+
|
43 |
+
class Sharechat(datasets.ArrowBasedBuilder):
|
44 |
+
"""The dataset for RecSys Challenge 2024."""
|
45 |
+
|
46 |
+
VERSION = datasets.Version("1.0.0")
|
47 |
+
|
48 |
+
# If you need to make complex sub-parts in the datasets with configurable options
|
49 |
+
# You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
|
50 |
+
# BUILDER_CONFIG_CLASS = MyBuilderConfig
|
51 |
+
|
52 |
+
BUILDER_CONFIGS = [
|
53 |
+
datasets.BuilderConfig(name="first_domain", version=VERSION, description="This part of my dataset covers a first domain"),
|
54 |
+
]
|
55 |
+
|
56 |
+
DEFAULT_CONFIG_NAME = "first_domain" # It's not mandatory to have a default configuration. Just use one if it make sense.
|
57 |
+
|
58 |
+
def _info(self):
|
59 |
+
if self.config.name == "first_domain": # This is the name of the configuration selected in BUILDER_CONFIGS above
|
60 |
+
# data format: f0,f1,...,f79, is_clicked, is_installed
|
61 |
+
# all_cat_columns = time_columns + cat_columns + binary_columns
|
62 |
+
id_columns = [('f_0', datasets.Value("int64"))]
|
63 |
+
time_columns = [('f_1', datasets.Value("int8"))]
|
64 |
+
cat_columns = [(f'f_{i}', datasets.Value("int32")) for i in range(2, 33)]
|
65 |
+
binary_columns = [(f'f_{i}', datasets.Value("int8")) for i in range(33, 42)]
|
66 |
+
dense_columns = [(f'f_{i}', datasets.Value("float")) for i in range(42, 80)]
|
67 |
+
other_columns = [('is_clicked', datasets.Value("int8"))]
|
68 |
+
label_columns = [('is_installed', datasets.Value("int8"))]
|
69 |
+
all_columns = id_columns + time_columns + cat_columns + binary_columns + dense_columns + other_columns + label_columns
|
70 |
+
|
71 |
+
features = datasets.Features(dict(all_columns))
|
72 |
+
else: # This is an example to show how to have different features for other domains
|
73 |
+
raise NotImplementedError("This configuration is not implemented yet")
|
74 |
+
return datasets.DatasetInfo(
|
75 |
+
# This is the description that will appear on the datasets page.
|
76 |
+
description=_DESCRIPTION,
|
77 |
+
# This defines the different columns of the dataset and their types
|
78 |
+
features=features, # Here we define them above because they are different between the two configurations
|
79 |
+
# If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
|
80 |
+
# specify them. They'll be used if as_supervised=True in builder.as_dataset.
|
81 |
+
# supervised_keys=("sentence", "label"),
|
82 |
+
# Homepage of the dataset for documentation
|
83 |
+
homepage=_HOMEPAGE,
|
84 |
+
# License for the dataset if available
|
85 |
+
license=_LICENSE,
|
86 |
+
# Citation for the dataset
|
87 |
+
citation=_CITATION,
|
88 |
+
)
|
89 |
+
|
90 |
+
def _split_generators(self, dl_manager):
|
91 |
+
# dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
|
92 |
+
# It can accept any type or nested list/dict and will give back the same structure with the url replaced with path to local files.
|
93 |
+
# By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
|
94 |
+
urls = _URLS[self.config.name]
|
95 |
+
data_dir = dl_manager.download_and_extract(urls)
|
96 |
+
|
97 |
+
id_columns = [('f_0', pl.Int64)]
|
98 |
+
time_columns = [('f_1', pl.Int8)]
|
99 |
+
cat_columns = [(f'f_{i}', pl.Int32) for i in range(2, 33)]
|
100 |
+
binary_columns = [(f'f_{i}', pl.Int8) for i in range(33, 42)]
|
101 |
+
dense_columns = [(f'f_{i}', pl.Float32) for i in range(42, 80)]
|
102 |
+
other_columns = [('is_clicked', pl.Int8)]
|
103 |
+
label_columns = [('is_installed', pl.Int8)]
|
104 |
+
all_columns = id_columns + time_columns + cat_columns + binary_columns + dense_columns + other_columns + label_columns
|
105 |
+
self.dtypes_dict = dict(all_columns)
|
106 |
+
|
107 |
+
return [
|
108 |
+
datasets.SplitGenerator(
|
109 |
+
name=datasets.Split.TRAIN,
|
110 |
+
gen_kwargs={
|
111 |
+
"filepaths": sorted(glob.glob(os.path.join(data_dir, "sharechat_recsys2023_data", "train", "*.csv"))),
|
112 |
+
"date_start": 45,
|
113 |
+
"date_end": 64,
|
114 |
+
},
|
115 |
+
),
|
116 |
+
datasets.SplitGenerator(
|
117 |
+
name=datasets.Split.VALIDATION,
|
118 |
+
gen_kwargs={
|
119 |
+
"filepaths": sorted(glob.glob(os.path.join(data_dir, "sharechat_recsys2023_data", "train", "*.csv"))),
|
120 |
+
"date_start": 65,
|
121 |
+
"date_end": 65,
|
122 |
+
},
|
123 |
+
),
|
124 |
+
datasets.SplitGenerator(
|
125 |
+
name=datasets.Split.TEST,
|
126 |
+
gen_kwargs={
|
127 |
+
"filepaths": sorted(glob.glob(os.path.join(data_dir, "sharechat_recsys2023_data", "train", "*.csv"))),
|
128 |
+
"date_start": 66,
|
129 |
+
"date_end": 66,
|
130 |
+
},
|
131 |
+
),
|
132 |
+
]
|
133 |
+
|
134 |
+
def _generate_tables(self, filepaths, date_start, date_end):
|
135 |
+
# This method handles input defined in _split_generators to yield (key, table) tuples from the dataset.
|
136 |
+
# The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
|
137 |
+
for id, filepath in enumerate(filepaths):
|
138 |
+
if self.config.name == "first_domain":
|
139 |
+
pa_table = (
|
140 |
+
pl.scan_csv(filepath, separator='\t', dtypes=self.dtypes_dict)
|
141 |
+
.filter(pl.col("f_1").is_between(date_start, date_end))
|
142 |
+
.sort("f_1", descending=False)
|
143 |
+
.with_columns(pl.col("f_1").mod(7).alias("f_1"))
|
144 |
+
.collect().to_arrow()
|
145 |
+
)
|
146 |
+
yield id, pa_table
|
147 |
+
else:
|
148 |
+
raise NotImplementedError
|
149 |
+
|
150 |
+
|
151 |
+
|
152 |
+
# test the script
|
153 |
+
# datasets-cli test sharechat.py --save_info --all_configs
|
154 |
+
# share the dataset
|
155 |
+
# huggingface-cli login
|
156 |
+
# huggingface-cli repo create sharechat-dataset --type dataset
|
157 |
+
# huggingface-cli upload sharechat-dataset . . --repo-type dataset
|