-
Notifications
You must be signed in to change notification settings - Fork 1k
/
test_co_clustering.py
32 lines (22 loc) · 1 KB
/
test_co_clustering.py
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
"""
Module for testing the CoClustering algorithm.
"""
from surprise import CoClustering
from surprise.model_selection import cross_validate
def test_CoClustering_parameters(u1_ml100k, pkf):
"""Ensure that all parameters are taken into account."""
# The baseline against which to compare.
algo = CoClustering(n_epochs=1, random_state=1)
rmse_default = cross_validate(algo, u1_ml100k, ['rmse'], pkf)['test_rmse']
# n_cltr_u
algo = CoClustering(n_cltr_u=1, n_epochs=1, random_state=1)
rmse_n_cltr_u = cross_validate(algo, u1_ml100k, ['rmse'], pkf)['test_rmse']
assert rmse_default != rmse_n_cltr_u
# n_cltr_i
algo = CoClustering(n_cltr_i=1, n_epochs=1, random_state=1)
rmse_n_cltr_i = cross_validate(algo, u1_ml100k, ['rmse'], pkf)['test_rmse']
assert rmse_default != rmse_n_cltr_i
# n_epochs
algo = CoClustering(n_epochs=2, random_state=1)
rmse_n_epochs = cross_validate(algo, u1_ml100k, ['rmse'], pkf)['test_rmse']
assert rmse_default != rmse_n_epochs