mstz commited on
Commit
5467f12
1 Parent(s): a29c826

Upload page_blocks.py

Browse files
Files changed (1) hide show
  1. page_blocks.py +0 -8
page_blocks.py CHANGED
@@ -91,7 +91,6 @@ class PageBlocks(datasets.GeneratorBasedBuilder):
91
 
92
  def _generate_examples(self, filepath: str):
93
  data = pandas.read_csv(filepath)
94
- print("preprocessing...\n\n\n\n\n")
95
  data = self.preprocess(data)
96
 
97
  for row_id, row in data.iterrows():
@@ -102,21 +101,14 @@ class PageBlocks(datasets.GeneratorBasedBuilder):
102
  def preprocess(self, data: pandas.DataFrame) -> pandas.DataFrame:
103
  if self.config.name == "page_blocks_binary":
104
  data["number_of_transitions"] = data["number_of_transitions"].apply(lambda x: 1 if x > 1 else 0)
105
- print("mapped\n\n\n\n")
106
  data = data.rename(columns={"number_of_transitions": "has_multiple_transitions"})
107
- print("renamed\n\n\n\n")
108
 
109
- print("encoding\n\n\n\n")
110
  for feature in _ENCODING_DICS:
111
  encoding_function = partial(self.encode, feature)
112
- print("\tencoding...\n\n\n\n")
113
  data.loc[:, feature] = data[feature].apply(encoding_function)
114
 
115
  data = data.reset_index()
116
  data.drop("index", axis="columns", inplace=True)
117
- print("encoded\n\n\n\n")
118
- print(list(features_types_per_config[self.config.name].keys()))
119
- print(data.head())
120
 
121
  return data[list(features_types_per_config[self.config.name].keys())]
122
 
 
91
 
92
  def _generate_examples(self, filepath: str):
93
  data = pandas.read_csv(filepath)
 
94
  data = self.preprocess(data)
95
 
96
  for row_id, row in data.iterrows():
 
101
  def preprocess(self, data: pandas.DataFrame) -> pandas.DataFrame:
102
  if self.config.name == "page_blocks_binary":
103
  data["number_of_transitions"] = data["number_of_transitions"].apply(lambda x: 1 if x > 1 else 0)
 
104
  data = data.rename(columns={"number_of_transitions": "has_multiple_transitions"})
 
105
 
 
106
  for feature in _ENCODING_DICS:
107
  encoding_function = partial(self.encode, feature)
 
108
  data.loc[:, feature] = data[feature].apply(encoding_function)
109
 
110
  data = data.reset_index()
111
  data.drop("index", axis="columns", inplace=True)
 
 
 
112
 
113
  return data[list(features_types_per_config[self.config.name].keys())]
114