Update
Browse files- test-dataset-debug.py +22 -15
test-dataset-debug.py
CHANGED
@@ -151,7 +151,7 @@ class Patents(datasets.GeneratorBasedBuilder):
|
|
151 |
# Download metadata
|
152 |
# NOTE: data_files is a path to a pickled pandas DataFrame
|
153 |
if self.config.data_files is None:
|
154 |
-
print(f'Loading
|
155 |
metadata_file = dl_manager.download_and_extract(_METADATA_URL)
|
156 |
else:
|
157 |
print(f'Using metadata file: {self.config.data_files}')
|
@@ -161,7 +161,7 @@ class Patents(datasets.GeneratorBasedBuilder):
|
|
161 |
# NOTE: data_dir is a path to a directory of json files, with one
|
162 |
# json file per patent application
|
163 |
if self.config.data_dir is None:
|
164 |
-
print('Loading
|
165 |
json_dir = Path(dl_manager.download_and_extract(_DATA_URL))
|
166 |
# NOTE: The extracted path contains a subfolder
|
167 |
json_dir = json_dir / _DATA_SUBFOLDER_NAME
|
@@ -185,6 +185,8 @@ class Patents(datasets.GeneratorBasedBuilder):
|
|
185 |
if self.config.query_string:
|
186 |
df = df.query(self.config.query_string)
|
187 |
|
|
|
|
|
188 |
# Return only one dataset
|
189 |
if self.config.train_only:
|
190 |
if self.config.train_filing_start_date:
|
@@ -220,20 +222,25 @@ class Patents(datasets.GeneratorBasedBuilder):
|
|
220 |
|
221 |
else:
|
222 |
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
# Does not assume that training_start_data < val_end_date
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
val_df = vdf[vdf['filing_date'] <= self.config.val_filing_end_date]
|
237 |
|
238 |
# TODO: Can make this step faster
|
239 |
if self.config.val_set_balancer:
|
|
|
151 |
# Download metadata
|
152 |
# NOTE: data_files is a path to a pickled pandas DataFrame
|
153 |
if self.config.data_files is None:
|
154 |
+
print(f'Loading or downloading metadata file: {_METADATA_URL}')
|
155 |
metadata_file = dl_manager.download_and_extract(_METADATA_URL)
|
156 |
else:
|
157 |
print(f'Using metadata file: {self.config.data_files}')
|
|
|
161 |
# NOTE: data_dir is a path to a directory of json files, with one
|
162 |
# json file per patent application
|
163 |
if self.config.data_dir is None:
|
164 |
+
print('Loading or downloading data. If downloading, watch out! This is a huge file (360GB)!')
|
165 |
json_dir = Path(dl_manager.download_and_extract(_DATA_URL))
|
166 |
# NOTE: The extracted path contains a subfolder
|
167 |
json_dir = json_dir / _DATA_SUBFOLDER_NAME
|
|
|
185 |
if self.config.query_string:
|
186 |
df = df.query(self.config.query_string)
|
187 |
|
188 |
+
|
189 |
+
|
190 |
# Return only one dataset
|
191 |
if self.config.train_only:
|
192 |
if self.config.train_filing_start_date:
|
|
|
222 |
|
223 |
else:
|
224 |
|
225 |
+
# Check
|
226 |
+
if not all(self.config.train_filing_start_date, self.config.train_filing_end_date,
|
227 |
+
self.config.val_filing_start_date, self.config.train_filing_end_date):
|
228 |
+
raise ValueError("Please either use uniform_split or specify your exact \
|
229 |
+
training and validation split dates.")
|
230 |
+
|
231 |
# Does not assume that training_start_data < val_end_date
|
232 |
+
print(f'Filtering train dataset by filing start date: {self.config.train_filing_start_date}')
|
233 |
+
print(f'Filtering train dataset by filing end date: {self.config.train_filing_end_date}')
|
234 |
+
print(f'Filtering val dataset by filing start date: {self.config.val_filing_start_date}')
|
235 |
+
print(f'Filtering val dataset by filing end date: {self.config.val_filing_end_date}')
|
236 |
+
train_df = df[
|
237 |
+
(df['filing_date'] >= self.config.train_filing_start_date) &
|
238 |
+
(df['filing_date'] < self.config.train_filing_end_date)
|
239 |
+
]
|
240 |
+
val_df = df[
|
241 |
+
(df['filing_date'] >= self.config.val_filing_start_date) &
|
242 |
+
(df['filing_date'] < self.config.val_filing_end_date)
|
243 |
+
]
|
|
|
244 |
|
245 |
# TODO: Can make this step faster
|
246 |
if self.config.val_set_balancer:
|