Francisco Castillo commited on
Commit
2d9ef74
1 Parent(s): b97dfef

First commit

Browse files
.gitattributes CHANGED
@@ -35,3 +35,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
35
  *.mp3 filter=lfs diff=lfs merge=lfs -text
36
  *.ogg filter=lfs diff=lfs merge=lfs -text
37
  *.wav filter=lfs diff=lfs merge=lfs -text
 
 
 
35
  *.mp3 filter=lfs diff=lfs merge=lfs -text
36
  *.ogg filter=lfs diff=lfs merge=lfs -text
37
  *.wav filter=lfs diff=lfs merge=lfs -text
38
+ production.csv filter=lfs diff=lfs merge=lfs -text
39
+ training.csv filter=lfs diff=lfs merge=lfs -text
40
+ validation.csv 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
+ licenses:
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
+ - text-classification
19
+ task_ids:
20
+ - sentiment-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.
ecommerce_reviews_language_drift.py ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 csv
20
+ import json
21
+ import os
22
+
23
+ import datasets
24
+ from datasets.tasks import TextClassification
25
+
26
+
27
+
28
+ # TODO: Add BibTeX citation to our BLOG
29
+ # Find for instance the citation on arxiv or on the dataset repo/website
30
+ _CITATION = ""
31
+ # _CITATION = """\
32
+ # @InProceedings{huggingface:dataset,
33
+ # title = {A great new dataset},
34
+ # author={huggingface, Inc.
35
+ # },
36
+ # year={2020}
37
+ # }
38
+ # """
39
+
40
+ # TODO: Add description of the dataset here
41
+ # You can copy an official description
42
+ _DESCRIPTION = """\
43
+ 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.
44
+ """
45
+
46
+ # TODO: Add a link to an official homepage for the dataset here
47
+ _HOMEPAGE = ""
48
+
49
+ # TODO: Add the licence for the dataset here if you can find it
50
+ _LICENSE = ""
51
+
52
+ # TODO: Add link to the official dataset URLs here
53
+ # The HuggingFace Datasets library doesn't host the datasets but only points to the original files.
54
+ # This can be an arbitrary nested dict/list of URLs (see below in `_split_generators` method)
55
+ _URL = "https://huggingface.co/datasets/arize-ai/reviews_with_drift/resolve/main/"
56
+ _URLS = {
57
+ "training": _URL + "training.csv",
58
+ "validation": _URL + "validation.csv",
59
+ "production": _URL + "production.csv",
60
+ }
61
+
62
+
63
+ # TODO: Name of the dataset usually match the script name with CamelCase instead of snake_case
64
+ class ReviewsWithDrift(datasets.GeneratorBasedBuilder):
65
+ """TODO: Short description of my dataset."""
66
+
67
+ VERSION = datasets.Version("1.0.0")
68
+
69
+ # This is an example of a dataset with multiple configurations.
70
+ # If you don't want/need to define several sub-sets in your dataset,
71
+ # just remove the BUILDER_CONFIG_CLASS and the BUILDER_CONFIGS attributes.
72
+
73
+ # If you need to make complex sub-parts in the datasets with configurable options
74
+ # You can create your own builder configuration class to store attribute, inheriting from datasets.BuilderConfig
75
+ # BUILDER_CONFIG_CLASS = MyBuilderConfig
76
+
77
+ # You will be able to load one or the other configurations in the following list with
78
+ # data = datasets.load_dataset('my_dataset', 'first_domain')
79
+ # data = datasets.load_dataset('my_dataset', 'second_domain')
80
+ BUILDER_CONFIGS = [
81
+ datasets.BuilderConfig(name="default", version=VERSION, description="Default"),
82
+ ]
83
+
84
+ DEFAULT_CONFIG_NAME = "default" # It's not mandatory to have a default configuration. Just use one if it make sense.
85
+
86
+ def _info(self):
87
+ class_names = ["negative", "positive"]
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
+ "age":datasets.Value("int16"),
94
+ "gender":datasets.Value("string"),
95
+ "context":datasets.Value("string"),
96
+ "text":datasets.Value("string"),
97
+ "label":datasets.ClassLabel(names=class_names),
98
+ }
99
+ )
100
+
101
+ return datasets.DatasetInfo(
102
+ # This is the description that will appear on the datasets page.
103
+ description=_DESCRIPTION,
104
+ # This defines the different columns of the dataset and their types
105
+ features=features, # Here we define them above because they are different between the two configurations
106
+ # If there's a common (input, target) tuple from the features, uncomment supervised_keys line below and
107
+ # specify them. They'll be used if as_supervised=True in builder.as_dataset.
108
+ supervised_keys=("text", "label"),
109
+ # Homepage of the dataset for documentation
110
+ # License for the dataset if available
111
+ license=_LICENSE,
112
+ # Citation for the dataset
113
+ citation=_CITATION,
114
+ task_templates=[TextClassification(text_column="text", label_column="label")],
115
+ )
116
+
117
+ def _split_generators(self, dl_manager):
118
+ # This method is tasked with downloading/extracting the data and defining the splits depending on the configuration
119
+ # If several configurations are possible (listed in BUILDER_CONFIGS), the configuration selected by the user is in self.config.name
120
+
121
+ # dl_manager is a datasets.download.DownloadManager that can be used to download and extract URLS
122
+ # 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.
123
+ # By default the archives will be extracted and a path to a cached folder where they are extracted is returned instead of the archive
124
+ extracted_paths = dl_manager.download_and_extract(_URLS)
125
+ return [
126
+ datasets.SplitGenerator(
127
+ name=datasets.Split("training"),
128
+ # These kwargs will be passed to _generate_examples
129
+ gen_kwargs={
130
+ "filepath": extracted_paths['training'],
131
+ },
132
+ ),
133
+ datasets.SplitGenerator(
134
+ name=datasets.Split("validation"),
135
+ # These kwargs will be passed to _generate_examples
136
+ gen_kwargs={
137
+ "filepath": extracted_paths['validation'],
138
+ },
139
+ ),
140
+ datasets.SplitGenerator(
141
+ name=datasets.Split("production"),
142
+ # These kwargs will be passed to _generate_examples
143
+ gen_kwargs={
144
+ "filepath": extracted_paths['production'],
145
+ },
146
+ ),
147
+ ]
148
+
149
+
150
+ # method parameters are unpacked from `gen_kwargs` as given in `_split_generators`
151
+ def _generate_examples(self, filepath):
152
+ # This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
153
+ # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
154
+ label_mapping = {"positive": 1, "negative": 0}
155
+ with open(filepath) as csv_file:
156
+ csv_reader = csv.reader(csv_file)
157
+ for id_, row in enumerate(csv_reader):
158
+ prediction_ts,age,gender,context,text,label = row
159
+ if id_==0:
160
+ continue
161
+ yield id_, {
162
+ "prediction_ts":prediction_ts,
163
+ "age":age,
164
+ "gender":gender,
165
+ "context":context,
166
+ "text": text,
167
+ "label":label,
168
+ }
production.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a560357f023b146b7dda6d6894edd2a3da9d0aa4422c5fc9123e7c0bb72b815f
3
+ size 9407130
training.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a814e4213e9ab15705e731ee075b6ad12e0c1e9b5abfc0b433088c10e2c496ee
3
+ size 2368468
validation.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:85eec516ed5e92f0138c93870150028263d66077fb48ad8859e75b455e5dd136
3
+ size 590320