Skip to content

Commit

Permalink
Merge pull request #592 from chenyushuo/master
Browse files Browse the repository at this point in the history
FEA: add config['benchmark_filename'] to load pre-split dataset.
  • Loading branch information
chenyushuo authored Dec 18, 2020
2 parents 45ff55d + e17710c commit 511cda8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion recbole/data/dataset/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ def copy(self, new_inter_feat):
:class:`~Dataset`: the new :class:`~Dataset` object, whose interaction feature has been updated.
"""
nxt = copy.copy(self)
nxt.inter_feat = new_inter_feat
nxt.inter_feat = pd.DataFrame(new_inter_feat)
return nxt

def _calcu_split_ids(self, tot, ratios):
Expand Down Expand Up @@ -1325,6 +1325,11 @@ def build(self, eval_setting):
Returns:
list: List of builded :class:`Dataset`.
"""
if self.benchmark_filename_list is not None:
cumsum = list(np.cumsum(self.file_size_list))
datasets = [self.copy(self.inter_feat[start: end]) for start, end in zip([0] + cumsum[:-1], cumsum)]
return datasets

ordering_args = eval_setting.ordering_args
if ordering_args['strategy'] == 'shuffle':
self.shuffle()
Expand Down
3 changes: 3 additions & 0 deletions recbole/trainer/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,9 @@ def evaluate(self, eval_data, load_best_model=True, model_file=None):
Returns:
dict: eval result, key is the eval metric and value in the corresponding metric value
"""
if not eval_data:
return

if load_best_model:
if model_file:
checkpoint_file = model_file
Expand Down

0 comments on commit 511cda8

Please sign in to comment.