Francisco Castillo commited on
Commit
ee1da52
1 Parent(s): c8a2709

First commit

Browse files
Files changed (6) hide show
  1. .gitattributes +3 -0
  2. README.md +142 -0
  3. cifar10_quality_drift.py +173 -0
  4. production.pkl +3 -0
  5. training.pkl +3 -0
  6. validation.pkl +3 -0
.gitattributes CHANGED
@@ -39,3 +39,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
39
  *.mp3 filter=lfs diff=lfs merge=lfs -text
40
  *.ogg filter=lfs diff=lfs merge=lfs -text
41
  *.wav filter=lfs diff=lfs merge=lfs -text
 
 
 
39
  *.mp3 filter=lfs diff=lfs merge=lfs -text
40
  *.ogg filter=lfs diff=lfs merge=lfs -text
41
  *.wav filter=lfs diff=lfs merge=lfs -text
42
+ production.pkl filter=lfs diff=lfs merge=lfs -text
43
+ training.pkl filter=lfs diff=lfs merge=lfs -text
44
+ validation.pkl filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ annotations_creators:
3
+ - expert-generated
4
+ language_creators:
5
+ - expert-generated
6
+ languages:
7
+ - en
8
+ license:
9
+ - mit
10
+ multilinguality:
11
+ - monolingual
12
+ pretty_name: sentiment-classification-reviews-with-drift
13
+ size_categories:
14
+ - 10K<n<100K
15
+ source_datasets:
16
+ - extended|imdb
17
+ task_categories:
18
+ - image-classification
19
+ task_ids:
20
+ - multi-class-classification
21
+ ---
22
+
23
+ # Dataset Card for `reviews_with_drift`
24
+
25
+ ## Table of Contents
26
+ - [Table of Contents](#table-of-contents)
27
+ - [Dataset Description](#dataset-description)
28
+ - [Dataset Summary](#dataset-summary)
29
+ - [Supported Tasks and Leaderboards](#supported-tasks-and-leaderboards)
30
+ - [Languages](#languages)
31
+ - [Dataset Structure](#dataset-structure)
32
+ - [Data Instances](#data-instances)
33
+ - [Data Fields](#data-fields)
34
+ - [Data Splits](#data-splits)
35
+ - [Dataset Creation](#dataset-creation)
36
+ - [Curation Rationale](#curation-rationale)
37
+ - [Source Data](#source-data)
38
+ - [Annotations](#annotations)
39
+ - [Personal and Sensitive Information](#personal-and-sensitive-information)
40
+ - [Considerations for Using the Data](#considerations-for-using-the-data)
41
+ - [Social Impact of Dataset](#social-impact-of-dataset)
42
+ - [Discussion of Biases](#discussion-of-biases)
43
+ - [Other Known Limitations](#other-known-limitations)
44
+ - [Additional Information](#additional-information)
45
+ - [Dataset Curators](#dataset-curators)
46
+ - [Licensing Information](#licensing-information)
47
+ - [Citation Information](#citation-information)
48
+ - [Contributions](#contributions)
49
+
50
+ ## Dataset Description
51
+
52
+ ### Dataset Summary
53
+
54
+ This dataset was crafted to be used in our tutorial [Link to the tutorial when ready]. It consists on a large Movie Review Dataset mixed with some reviews from a Hotel Review Dataset. The training/validation set are purely obtained from the Movie Review Dataset while the production set is mixed. Some other features have been added (`age`, `gender`, `context`) as well as a made up timestamp `prediction_ts` of when the inference took place.
55
+
56
+ ### Supported Tasks and Leaderboards
57
+
58
+ `text-classification`, `sentiment-classification`: The dataset is mainly used for text classification: given the text, predict the sentiment (positive or negative).
59
+
60
+ ### Languages
61
+
62
+ Text is mainly written in english.
63
+
64
+ ## Dataset Structure
65
+
66
+ ### Data Instances
67
+
68
+ [More Information Needed]
69
+
70
+ ### Data Fields
71
+
72
+ [More Information Needed]
73
+
74
+ ### Data Splits
75
+
76
+ [More Information Needed]
77
+
78
+ ## Dataset Creation
79
+
80
+ ### Curation Rationale
81
+
82
+ [More Information Needed]
83
+
84
+ ### Source Data
85
+
86
+ [More Information Needed]
87
+
88
+ #### Initial Data Collection and Normalization
89
+
90
+ [More Information Needed]
91
+
92
+ #### Who are the source language producers?
93
+
94
+ [More Information Needed]
95
+
96
+ ### Annotations
97
+
98
+ [More Information Needed]
99
+
100
+ #### Annotation process
101
+
102
+ [More Information Needed]
103
+
104
+ #### Who are the annotators?
105
+
106
+ [More Information Needed]
107
+
108
+ ### Personal and Sensitive Information
109
+
110
+ [More Information Needed]
111
+
112
+ ## Considerations for Using the Data
113
+
114
+ ### Social Impact of Dataset
115
+
116
+ [More Information Needed]
117
+
118
+ ### Discussion of Biases
119
+
120
+ [More Information Needed]
121
+
122
+ ### Other Known Limitations
123
+
124
+ [More Information Needed]
125
+
126
+ ## Additional Information
127
+
128
+ ### Dataset Curators
129
+
130
+ [More Information Needed]
131
+
132
+ ### Licensing Information
133
+
134
+ [More Information Needed]
135
+
136
+ ### Citation Information
137
+
138
+ [More Information Needed]
139
+
140
+ ### Contributions
141
+
142
+ Thanks to [@fjcasti1](https://github.com/fjcasti1) for adding this dataset.
cifar10_quality_drift.py ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2020 The HuggingFace Datasets Authors and the current dataset script contributor.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ # Lint as: python3
16
+ """IMDb movie revies dataset mixed with Trip Advisor Hotel Reviews to simulate drift accross time."""
17
+
18
+
19
+ import datasets
20
+ import pickle5 as pickle
21
+
22
+
23
+
24
+ # TODO: Add BibTeX citation to our BLOG
25
+ # Find for instance the citation on arxiv or on the dataset repo/website
26
+ _CITATION = ""
27
+ # _CITATION = """\
28
+ # @InProceedings{huggingface:dataset,
29
+ # title = {A great new dataset},
30
+ # author={huggingface, Inc.
31
+ # },
32
+ # year={2020}
33
+ # }
34
+ # """
35
+
36
+ # TODO: Add description of the dataset here
37
+ # You can copy an official description
38
+ _DESCRIPTION = """\
39
+ This dataset was crafted to be used in our tutorial [Link to the tutorial when
40
+ ready]. It consists on product reviews from an e-commerce store. The reviews
41
+ are labeled on a scale from 1 to 5 (stars). The training & validation sets are
42
+ fully composed by reviews written in english. However, the production set has
43
+ some reviews written in spanish. At Arize, we work to surface this issue and
44
+ help you solve it.
45
+ """
46
+
47
+ # TODO: Add a link to an official homepage for the dataset here
48
+ _HOMEPAGE = ""
49
+
50
+ # TODO: Add the licence for the dataset here if you can find it
51
+ _LICENSE = ""
52
+
53
+ # TODO: Add link to the official dataset URLs here
54
+ # The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
55
+ # This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
56
+ _URL = "https://huggingface.co/datasets/arize-ai/cifar10_quality_drift/resolve/main/"
57
+ _URLS = {
58
+ "training": _URL + "training.pkl",
59
+ "validation": _URL + "validation.pkl",
60
+ "production": _URL + "production.pkl",
61
+ }
62
+
63
+
64
+ # TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
65
+ class Cifar10QualityDrift(datasets.GeneratorBasedBuilder):
66
+ """TODO: Short description of my dataset."""
67
+
68
+ VERSION = datasets.Version("1.0.0")
69
+
70
+ # This is an example of a dataset with multiple configurations.
71
+ # If you don't want/need to define several sub-sets in your dataset,
72
+ # just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
73
+
74
+ # If you need to make complex sub-parts in the datasets with configurable options
75
+ # You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
76
+ # BUILDER_CONFIG_CLASS = MyBuilderConfig
77
+
78
+ # You will be able to load one or the other configurations in the following list with
79
+ # data = datasets.load_dataset('my_dataset', 'first_domain')
80
+ # data = datasets.load_dataset('my_dataset', 'second_domain')
81
+ BUILDER_CONFIGS = [
82
+ datasets.BuilderConfig(name="default", version=VERSION, description="Default"),
83
+ ]
84
+
85
+ DEFAULT_CONFIG_NAME = "default" # It's not mandatory to have a default configuration. Just use one if it make sense.
86
+
87
+ def _info(self):
88
+ # This method specifies the datasets.DatasetInfo object which contains informations and typings for the dataset
89
+ features = datasets.Features(
90
+ # These are the features of your dataset like images, labels ...
91
+ {
92
+ "prediction_ts": datasets.Value("float"),
93
+ "image": datasets.Image(decode=True),
94
+ "label": datasets.features.ClassLabel(
95
+ names= [
96
+ 'airplane',
97
+ 'automobile',
98
+ 'bird',
99
+ 'cat',
100
+ 'deer',
101
+ 'dog',
102
+ 'frog',
103
+ 'horse',
104
+ 'ship',
105
+ 'truck'
106
+ ]
107
+ ),
108
+ "url": datasets.Value("string"),
109
+ }
110
+ )
111
+
112
+ return datasets.DatasetInfo(
113
+ # This is the description that will appear on the datasets page.
114
+ description=_DESCRIPTION,
115
+ # This defines the different columns of the dataset and their types
116
+ features=features, # Here we define them above because they are different between the two configurations
117
+ # Homepage of the dataset for documentation
118
+ # License for the dataset if available
119
+ license=_LICENSE,
120
+ # Citation for the dataset
121
+ citation=_CITATION,
122
+ )
123
+
124
+ def _split_generators(self, dl_manager):
125
+ # This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
126
+ # If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
127
+
128
+ # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
129
+ # 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.
130
+ # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
131
+ extracted_paths = dl_manager.download_and_extract(_URLS)
132
+ return [
133
+ datasets.SplitGenerator(
134
+ name=datasets.Split("training"),
135
+ # These kwargs will be passed to _generate_examples
136
+ gen_kwargs={
137
+ "filepath": extracted_paths['training'],
138
+ },
139
+ ),
140
+ datasets.SplitGenerator(
141
+ name=datasets.Split("validation"),
142
+ # These kwargs will be passed to _generate_examples
143
+ gen_kwargs={
144
+ "filepath": extracted_paths['validation'],
145
+ },
146
+ ),
147
+ datasets.SplitGenerator(
148
+ name=datasets.Split("production"),
149
+ # These kwargs will be passed to _generate_examples
150
+ gen_kwargs={
151
+ "filepath": extracted_paths['production'],
152
+ },
153
+ ),
154
+ ]
155
+
156
+
157
+ # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
158
+ def _generate_examples(self, filepath):
159
+ # This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
160
+ # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
161
+ with open(filepath, 'rb') as pkl_file:
162
+ data = pickle.load(pkl_file, encoding='bytes')
163
+ prediction_ts=data['prediction_ts']
164
+ images=data['image']
165
+ labels=data['label']
166
+ urls=data['url']
167
+ for idx, _ in enumerate(images):
168
+ yield idx, {
169
+ "prediction_ts":prediction_ts[idx],
170
+ "image":images[idx],
171
+ "label":int(labels[idx]),
172
+ "url":urls[idx]
173
+ }
production.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:84af2386b6dcef59662d8206aec5f5f08efcd2d4fa9238d79de3b5766a1e1f23
3
+ size 120767860
training.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:900ce3f1aac9cddf46236218cf3b147a3f6ea6bae70a2e6b13b49c96346fa663
3
+ size 19467411
validation.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dc4d2cf1c27df85c6ef3d847898e0c324f08c2251bbcef6ff50e863b2d978254
3
+ size 4870796