-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathconftest.py
More file actions
53 lines (35 loc) · 1.27 KB
/
Copy pathconftest.py
File metadata and controls
53 lines (35 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""
This module contains the pytest fixtures.
"""
import os
import pytest
from surprise import Dataset, Reader
from surprise.model_selection import PredefinedKFold
@pytest.fixture
def toy_data_reader():
return Reader(
line_format="user item rating", sep=" ", skip_lines=3, rating_scale=(1, 5)
)
@pytest.fixture
def toy_data(toy_data_reader):
toy_data_path = os.path.dirname(os.path.realpath(__file__)) + "/custom_dataset"
data = Dataset.load_from_file(file_path=toy_data_path, reader=toy_data_reader)
return data
@pytest.fixture
def u1_ml100k():
"""Return a Dataset object that contains 10% of the u1 fold from movielens
100k. Trainset has 8000 ratings and testset has 2000.
"""
train_file = os.path.join(os.path.dirname(__file__), "./u1_ml100k_train")
test_file = os.path.join(os.path.dirname(__file__), "./u1_ml100k_test")
data = Dataset.load_from_folds([(train_file, test_file)], Reader("ml-100k"))
return data
@pytest.fixture
def small_ml():
"""Return a Dataset object with 2000 movielens-100k ratings."""
data_file = os.path.join(os.path.dirname(__file__), "./u1_ml100k_test")
data = Dataset.load_from_file(data_file, Reader("ml-100k"))
return data
@pytest.fixture
def pkf():
return PredefinedKFold()