src.fairreckitlib.model.algorithms.implicit.implicit_params

This module contains the parameter creation functions for implicit recommenders.

Functions:

create_params_als: create AlternatingLeastSquares config parameters.
create_params_bpr: create BayesianPersonalizedRanking config parameters.
create_params_lmf: create LogisticMatrixFactorization 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 implicit recommenders.
 2
 3Functions:
 4
 5    create_params_als: create AlternatingLeastSquares config parameters.
 6    create_params_bpr: create BayesianPersonalizedRanking config parameters.
 7    create_params_lmf: create LogisticMatrixFactorization config parameters.
 8
 9This program has been developed by students from the bachelor Computer Science at
10Utrecht University within the Software Project course.
11© Copyright Utrecht University (Department of Information and Computing Sciences)
12"""
13
14from ....core.config.config_parameters import ConfigParameters
15
16
17def create_params_als() -> ConfigParameters:
18    """Create the parameters of the AlternatingLeastSquares algorithm.
19
20    Returns:
21        the configuration parameters of the algorithm.
22    """
23    params = ConfigParameters()
24    params.add_number('factors', int, 100, (1, 100))
25    params.add_number('iterations', int, 15, (1, 50))
26    params.add_number('regularization', float, 0.01, (0.0001, 1.0))
27    params.add_random_seed('random_seed')
28    params.add_bool('calculate_training_loss', False)
29    params.add_bool('use_cg', True)
30    params.add_bool('use_native', True)
31    return params
32
33
34def create_params_bpr() -> ConfigParameters:
35    """Create the parameters of the BayesianPersonalizedRanking algorithm.
36
37    Returns:
38        the configuration parameters of the algorithm.
39    """
40    params = ConfigParameters()
41    params.add_number('factors', int, 100, (1, 100))
42    params.add_number('iterations', int, 100, (1, 1000))
43    params.add_number('regularization', float, 0.01, (0.0001, 1.0))
44    params.add_number('learning_rate', float, 0.01, (0.0001, 1.0))
45    params.add_random_seed('random_seed')
46    params.add_bool('verify_negative_samples', True)
47    return params
48
49
50def create_params_lmf() -> ConfigParameters:
51    """Create the parameters of the LogisticMatrixFactorization algorithm.
52
53    Returns:
54        the configuration parameters of the algorithm.
55    """
56    params = ConfigParameters()
57    params.add_number('factors', int, 30, (1, 100))
58    params.add_number('iterations', int, 30, (1, 100))
59    params.add_number('regularization', float, 0.6, (0.0001, 1.0))
60    params.add_number('learning_rate', float, 1.0, (0.0001, 1.0))
61    params.add_number('neg_prop', int, 30, (1, 50))
62    params.add_random_seed('random_seed')
63    return params
def create_params_als() -> src.fairreckitlib.core.config.config_parameters.ConfigParameters:
18def create_params_als() -> ConfigParameters:
19    """Create the parameters of the AlternatingLeastSquares algorithm.
20
21    Returns:
22        the configuration parameters of the algorithm.
23    """
24    params = ConfigParameters()
25    params.add_number('factors', int, 100, (1, 100))
26    params.add_number('iterations', int, 15, (1, 50))
27    params.add_number('regularization', float, 0.01, (0.0001, 1.0))
28    params.add_random_seed('random_seed')
29    params.add_bool('calculate_training_loss', False)
30    params.add_bool('use_cg', True)
31    params.add_bool('use_native', True)
32    return params

Create the parameters of the AlternatingLeastSquares algorithm.

Returns: the configuration parameters of the algorithm.

def create_params_bpr() -> src.fairreckitlib.core.config.config_parameters.ConfigParameters:
35def create_params_bpr() -> ConfigParameters:
36    """Create the parameters of the BayesianPersonalizedRanking algorithm.
37
38    Returns:
39        the configuration parameters of the algorithm.
40    """
41    params = ConfigParameters()
42    params.add_number('factors', int, 100, (1, 100))
43    params.add_number('iterations', int, 100, (1, 1000))
44    params.add_number('regularization', float, 0.01, (0.0001, 1.0))
45    params.add_number('learning_rate', float, 0.01, (0.0001, 1.0))
46    params.add_random_seed('random_seed')
47    params.add_bool('verify_negative_samples', True)
48    return params

Create the parameters of the BayesianPersonalizedRanking algorithm.

Returns: the configuration parameters of the algorithm.

def create_params_lmf() -> src.fairreckitlib.core.config.config_parameters.ConfigParameters:
51def create_params_lmf() -> ConfigParameters:
52    """Create the parameters of the LogisticMatrixFactorization algorithm.
53
54    Returns:
55        the configuration parameters of the algorithm.
56    """
57    params = ConfigParameters()
58    params.add_number('factors', int, 30, (1, 100))
59    params.add_number('iterations', int, 30, (1, 100))
60    params.add_number('regularization', float, 0.6, (0.0001, 1.0))
61    params.add_number('learning_rate', float, 1.0, (0.0001, 1.0))
62    params.add_number('neg_prop', int, 30, (1, 50))
63    params.add_random_seed('random_seed')
64    return params

Create the parameters of the LogisticMatrixFactorization algorithm.

Returns: the configuration parameters of the algorithm.