src.fairreckitlib.model.algorithms.lenskit.lenskit_params

This module contains the parameter creation functions for lenskit predictors/recommenders.

Functions:

create_params_biased_mf: create BiasedMF config parameters.
create_params_implicit_mf: create ImplicitMF config parameters.
create_params_knn: create ItemItem/UserUser config parameters.
create_params_pop_score: create PopScore config parameters.

This program has been developed by students from the bachelor Computer Science at Utrecht University within the Software Project course. © Copyright Utrecht University (Department of Information and Computing Sciences)

 1"""This module contains the parameter creation functions for lenskit predictors/recommenders.
 2
 3Functions:
 4
 5    create_params_biased_mf: create BiasedMF config parameters.
 6    create_params_implicit_mf: create ImplicitMF config parameters.
 7    create_params_knn: create ItemItem/UserUser config parameters.
 8    create_params_pop_score: create PopScore config parameters.
 9
10This program has been developed by students from the bachelor Computer Science at
11Utrecht University within the Software Project course.
12© Copyright Utrecht University (Department of Information and Computing Sciences)
13"""
14
15from ....core.config.config_parameters import ConfigParameters
16
17
18def create_params_biased_mf() -> ConfigParameters:
19    """Create the parameters of the BiasedMF algorithm.
20
21    Returns:
22        the configuration parameters of the algorithm.
23    """
24    methods = ['cd', 'lu']
25
26    params = ConfigParameters()
27    params.add_number('features', int, 10, (1, 50))
28    params.add_number('iterations', int, 20, (1, 50))
29    params.add_number('user_reg', float, 0.1, (0.0001, 1.0))
30    params.add_number('item_reg', float, 0.1, (0.0001, 1.0))
31    params.add_number('damping', float, 5.0, (0.0, 1000.0))
32    params.add_random_seed('seed')
33    params.add_single_option('method', str, methods[0], methods)
34    return params
35
36
37def create_params_implicit_mf() -> ConfigParameters:
38    """Create the parameters of the ImplicitMF algorithm.
39
40    Returns:
41        the configuration parameters of the algorithm.
42    """
43    methods = ['cg', 'lu']
44
45    params = ConfigParameters()
46    params.add_number('features', int, 3, (1, 50))
47    params.add_number('iterations', int, 20, (1, 50))
48    params.add_number('reg', float, 0.1, (0.0001, 1.0))
49    params.add_number('weight', float, 40.0, (1.0, 10000.0))
50    params.add_random_seed('seed')
51    params.add_single_option('method', str, methods[0], methods)
52    params.add_bool('use_ratings', False)
53    return params
54
55
56def create_params_knn() -> ConfigParameters:
57    """Create the parameters of the k-NN algorithms.
58
59    Returns:
60        the configuration parameters of the algorithm.
61    """
62    params = ConfigParameters()
63    params.add_number('max_neighbors', int, 10, (1, 50))
64    params.add_number('min_neighbors', int, 1, (1, 50))
65    params.add_number('min_similarity', float, 1e-06, (0.0, 10.0))
66    return params
67
68
69def create_params_pop_score() -> ConfigParameters:
70    """Create the parameters of the PopScore algorithm.
71
72    Returns:
73        the configuration parameters of the algorithm.
74    """
75    options = ['quantile', 'rank', 'count']
76
77    params = ConfigParameters()
78    params.add_single_option('score_method', str, options[0], options)
79    return params
def create_params_biased_mf() -> src.fairreckitlib.core.config.config_parameters.ConfigParameters:
19def create_params_biased_mf() -> ConfigParameters:
20    """Create the parameters of the BiasedMF algorithm.
21
22    Returns:
23        the configuration parameters of the algorithm.
24    """
25    methods = ['cd', 'lu']
26
27    params = ConfigParameters()
28    params.add_number('features', int, 10, (1, 50))
29    params.add_number('iterations', int, 20, (1, 50))
30    params.add_number('user_reg', float, 0.1, (0.0001, 1.0))
31    params.add_number('item_reg', float, 0.1, (0.0001, 1.0))
32    params.add_number('damping', float, 5.0, (0.0, 1000.0))
33    params.add_random_seed('seed')
34    params.add_single_option('method', str, methods[0], methods)
35    return params

Create the parameters of the BiasedMF algorithm.

Returns: the configuration parameters of the algorithm.

def create_params_implicit_mf() -> src.fairreckitlib.core.config.config_parameters.ConfigParameters:
38def create_params_implicit_mf() -> ConfigParameters:
39    """Create the parameters of the ImplicitMF algorithm.
40
41    Returns:
42        the configuration parameters of the algorithm.
43    """
44    methods = ['cg', 'lu']
45
46    params = ConfigParameters()
47    params.add_number('features', int, 3, (1, 50))
48    params.add_number('iterations', int, 20, (1, 50))
49    params.add_number('reg', float, 0.1, (0.0001, 1.0))
50    params.add_number('weight', float, 40.0, (1.0, 10000.0))
51    params.add_random_seed('seed')
52    params.add_single_option('method', str, methods[0], methods)
53    params.add_bool('use_ratings', False)
54    return params

Create the parameters of the ImplicitMF algorithm.

Returns: the configuration parameters of the algorithm.

def create_params_knn() -> src.fairreckitlib.core.config.config_parameters.ConfigParameters:
57def create_params_knn() -> ConfigParameters:
58    """Create the parameters of the k-NN algorithms.
59
60    Returns:
61        the configuration parameters of the algorithm.
62    """
63    params = ConfigParameters()
64    params.add_number('max_neighbors', int, 10, (1, 50))
65    params.add_number('min_neighbors', int, 1, (1, 50))
66    params.add_number('min_similarity', float, 1e-06, (0.0, 10.0))
67    return params

Create the parameters of the k-NN algorithms.

Returns: the configuration parameters of the algorithm.

def create_params_pop_score() -> src.fairreckitlib.core.config.config_parameters.ConfigParameters:
70def create_params_pop_score() -> ConfigParameters:
71    """Create the parameters of the PopScore algorithm.
72
73    Returns:
74        the configuration parameters of the algorithm.
75    """
76    options = ['quantile', 'rank', 'count']
77
78    params = ConfigParameters()
79    params.add_single_option('score_method', str, options[0], options)
80    return params

Create the parameters of the PopScore algorithm.

Returns: the configuration parameters of the algorithm.