Francisco Castillo commited on
Commit
5b44395
1 Parent(s): 9fe0261
Files changed (1) hide show
  1. fashion_mnist_label_drift.py +20 -16
fashion_mnist_label_drift.py CHANGED
@@ -17,6 +17,7 @@
17
 
18
 
19
  import csv
 
20
  import datasets
21
 
22
 
@@ -158,22 +159,25 @@ class FashionMNISTLabelDrift(datasets.GeneratorBasedBuilder):
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
-
162
- with open(filepath) as csv_file:
163
- csv_reader = csv.reader(csv_file, delimiter='\t')
164
- for id_, row in enumerate(csv_reader):
165
- prediction_ts,language,text,ner_tags = row
166
- ner_tags_list = list(ner_tags.strip('[]').split(' '))
167
- tokens = text.split(":-:")
168
- if id_==0:
169
- continue
170
- yield id_, {
171
- "prediction_ts":prediction_ts,
172
- "language":language,
173
- "split_text": tokens,
174
- "ner_tags":ner_tags_list,
175
- }
176
-
 
 
 
177
  #def _generate_examples(self, filepath, split):
178
  # """This function returns the examples in the raw form."""
179
  # # Images
 
17
 
18
 
19
  import csv
20
+ import pandas as pd
21
  import datasets
22
 
23
 
 
159
  def _generate_examples(self, filepath):
160
  # This method handles input defined in _split_generators to yield (key, example) tuples from the dataset.
161
  # The `key` is for legacy reasons (tfds) and is not important in itself, but must be unique for each example.
162
+ df = pd.read_hdf(filepath)
163
+ print(len(df))
164
+ print(df.columns)
165
+
166
+ # with open(filepath) as csv_file:
167
+ # csv_reader = csv.reader(csv_file, delimiter='\t')
168
+ # for id_, row in enumerate(csv_reader):
169
+ # prediction_ts,language,text,ner_tags = row
170
+ # ner_tags_list = list(ner_tags.strip('[]').split(' '))
171
+ # tokens = text.split(":-:")
172
+ # if id_==0:
173
+ # continue
174
+ # yield id_, {
175
+ # "prediction_ts":prediction_ts,
176
+ # "language":language,
177
+ # "split_text": tokens,
178
+ # "ner_tags":ner_tags_list,
179
+ # }
180
+ #
181
  #def _generate_examples(self, filepath, split):
182
  # """This function returns the examples in the raw form."""
183
  # # Images