Skip to content

Commit

Permalink
Merge pull request #2 from RUCAIBox/0.2.x
Browse files Browse the repository at this point in the history
merge from 0.2.x
  • Loading branch information
chenyushuo authored Nov 19, 2020
2 parents ea1c7aa + 6258d54 commit 4cb8119
Show file tree
Hide file tree
Showing 14 changed files with 18,410 additions and 186 deletions.
19 changes: 16 additions & 3 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Python package
name: RecBole tests

on:
- push
Expand All @@ -22,12 +22,25 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install pytest
pip install dgl
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
# Use "python -m pytest" instead of "pytest" to fix imports
- name: Test metrics
run: |
python -m pytest tests/metrics
python -m pytest -v tests/metrics
- name: Test evaluation_setting
run: |
python -m pytest tests/evaluation_setting
python -m pytest -v tests/evaluation_setting
- name: Test model
run: |
python -m pytest -v tests/model/test_model_auto.py
- name: Test config
run: |
python -m pytest -v tests/config/test_config.py
export PYTHONPATH=.
python tests/config/test_command_line.py --use_gpu=False --valid_metric=Recall@10 --split_ratio=[0.7,0.2,0.1] --metrics=['Recall@10'] --epochs=200 --eval_setting='LO_RS' --learning_rate=0.3
- name: Test evaluation_setting
run: |
python -m pytest -v tests/evaluation_setting
1 change: 1 addition & 0 deletions recbole/data/dataloader/general_dataloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def _neg_sampling(self, inter_feat):
return self.sampling_func(uid_field, iid_field, neg_iids, inter_feat)

def _neg_sample_by_pair_wise_sampling(self, uid_field, iid_field, neg_iids, inter_feat):
inter_feat = pd.concat([inter_feat] * self.times, ignore_index=True)
inter_feat.insert(len(inter_feat.columns), self.neg_item_id, neg_iids)

if self.dataset.item_feat is not None:
Expand Down
4 changes: 1 addition & 3 deletions recbole/data/dataloader/neg_sample_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ def __init__(self, config, dataset, sampler, neg_sample_args,
batch_size=1, dl_format=InputType.POINTWISE, shuffle=False):
if neg_sample_args['strategy'] != 'by':
raise ValueError('neg_sample strategy in GeneralInteractionBasedDataLoader() should be `by`')
if dl_format == InputType.PAIRWISE and neg_sample_args['by'] != 1:
raise ValueError('Pairwise dataloader can only neg sample by 1')

self.user_inter_in_one_batch = (sampler.phase != 'train') and (config['eval_type'] != EvaluatorType.INDIVIDUAL)
self.neg_sample_by = neg_sample_args['by']
Expand All @@ -109,7 +107,7 @@ def __init__(self, config, dataset, sampler, neg_sample_args,
self.label_field = config['LABEL_FIELD']
dataset.set_field_property(self.label_field, FeatureType.FLOAT, FeatureSource.INTERACTION, 1)
elif dl_format == InputType.PAIRWISE:
self.times = 1
self.times = self.neg_sample_by
self.sampling_func = self._neg_sample_by_pair_wise_sampling

neg_prefix = config['NEG_PREFIX']
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ hyperopt>=0.2.4
pandas>=1.0.5
tqdm>=4.48.2
scikit_learn>=0.23.2
pyyaml>=5.1.0
pyyaml>=5.1.0
7 changes: 5 additions & 2 deletions tests/config/test_overall.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
# @Author : Kaiyuan Li
# @email : tsotfsk@outlook.com


# UPDATE:
# @Time : 2020/11/17
# @Author : Xingyu Pan
# @Email : panxy@ruc.edu.cn
import os
import sys
import unittest
Expand Down Expand Up @@ -119,7 +122,7 @@ def test_split_ratio(self):
}

self.assertTrue(run_parms({'split_ratio':[ # [0.8, 0.2],
[0.8, 0.1, 0.1], [7, 1, 1, 1], [16, 2, 2]]}))
[0.8, 0.1, 0.1], [16, 2, 2]]}))

def test_leave_one_num(self):
settings = {
Expand Down
Loading

0 comments on commit 4cb8119

Please sign in to comment.