src.fairreckitlib.model.algorithms.surprise.surprise_recommender
This module contains the surprise top k predictor creation functions.
Functions:
create_baseline_only_als: create BaselineOnly ALS recommender (factory creation compatible).
create_baseline_only_sgd: create BaselineOnly SGD recommender (factory creation compatible).
create_co_clustering: create CoClustering recommender (factory creation compatible).
create_knn_basic: create KNNBasic recommender (factory creation compatible).
create_knn_baseline_als: create KNNBaseline ALS recommender (factory creation compatible).
create_knn_baseline_sgd: create KNNBaseline SGD recommender (factory creation compatible).
create_knn_with_means: create KNNWithMeans recommender (factory creation compatible).
create_knn_with_zscore: create KNNWithZScore recommender (factory creation compatible).
create_nmf: create NMF recommender (factory creation compatible).
create_normal_predictor: create NormalPredictor recommender (factory creation compatible).
create_slope_one: create SlopeOne recommender (factory creation compatible).
create_svd: create SVD recommender (factory creation compatible).
create_svd_pp: create SVDpp recommender (factory creation compatible).
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 surprise top k predictor creation functions. 2 3Functions: 4 5 create_baseline_only_als: create BaselineOnly ALS recommender (factory creation compatible). 6 create_baseline_only_sgd: create BaselineOnly SGD recommender (factory creation compatible). 7 create_co_clustering: create CoClustering recommender (factory creation compatible). 8 create_knn_basic: create KNNBasic recommender (factory creation compatible). 9 create_knn_baseline_als: create KNNBaseline ALS recommender (factory creation compatible). 10 create_knn_baseline_sgd: create KNNBaseline SGD recommender (factory creation compatible). 11 create_knn_with_means: create KNNWithMeans recommender (factory creation compatible). 12 create_knn_with_zscore: create KNNWithZScore recommender (factory creation compatible). 13 create_nmf: create NMF recommender (factory creation compatible). 14 create_normal_predictor: create NormalPredictor recommender (factory creation compatible). 15 create_slope_one: create SlopeOne recommender (factory creation compatible). 16 create_svd: create SVD recommender (factory creation compatible). 17 create_svd_pp: create SVDpp recommender (factory creation compatible). 18 19This program has been developed by students from the bachelor Computer Science at 20Utrecht University within the Software Project course. 21© Copyright Utrecht University (Department of Information and Computing Sciences) 22""" 23 24from typing import Any, Dict 25 26from ..top_k_recommender import TopK 27from . import surprise_predictor 28 29 30def create_baseline_only_als(name: str, params: Dict[str, Any], **kwargs) -> TopK: 31 """Create the BaselineOnly ALS recommender. 32 33 Args: 34 name: the name of the algorithm. 35 params: containing the following name-value pairs: 36 epochs(int): The number of iteration of the ALS procedure. 37 reg_i(int): the regularization parameter for items. 38 reg_u(int): The regularization parameter for items. 39 40 Returns: 41 the SurprisePredictor wrapper of BaselineOnly with method 'als' as a TopK recommender. 42 """ 43 predictor = surprise_predictor.create_baseline_only_als(name, params, **kwargs) 44 return TopK(predictor, kwargs['rated_items_filter']) 45 46 47def create_baseline_only_sgd(name: str, params: Dict[str, Any], **kwargs) -> TopK: 48 """Create the BaselineOnly SGD recommender. 49 50 Args: 51 name: the name of the algorithm. 52 params: containing the following name-value pairs: 53 epochs(int): the number of iteration of the SGD procedure. 54 regularization(float): the regularization parameter 55 of the cost function that is optimized. 56 learning_rate(float): the learning rate of SGD. 57 58 Returns: 59 the SurprisePredictor wrapper of BaselineOnly with method 'sgd' as a TopK recommender. 60 """ 61 predictor = surprise_predictor.create_baseline_only_sgd(name, params, **kwargs) 62 return TopK(predictor, kwargs['rated_items_filter']) 63 64 65def create_co_clustering(name: str, params: Dict[str, Any], **kwargs) -> TopK: 66 """Create the CoClustering recommender. 67 68 Args: 69 name: the name of the algorithm. 70 params: containing the following name-value pairs: 71 epochs(int): number of iteration of the optimization loop. 72 user_clusters(int): number of user clusters. 73 item_clusters(int): number of item clusters. 74 random_seed(int): the random seed or None for the current time as seed. 75 76 Returns: 77 the SurprisePredictor wrapper of CoClustering as a TopK recommender. 78 """ 79 predictor = surprise_predictor.create_co_clustering(name, params, **kwargs) 80 return TopK(predictor, kwargs['rated_items_filter']) 81 82 83def create_knn_basic(name: str, params: Dict[str, Any], **kwargs) -> TopK: 84 """Create the KNNBasic recommender. 85 86 Args: 87 name: the name of the algorithm. 88 params: containing the following name-value pairs: 89 max_k(int): the maximum number of neighbors to take into account for aggregation. 90 min_k(int): the minimum number of neighbors to take into account for aggregation. 91 user_based(bool): whether similarities will be computed between users or between 92 items, this has a huge impact on the performance. 93 min_support(int): the minimum number of common items or users, depending on the 94 user_based parameter. 95 similarity(str): the name of the similarity to use ('MSD', 'cosine' or 'pearson'). 96 97 Returns: 98 the SurprisePredictor wrapper of KNNBasic as a TopK recommender. 99 """ 100 predictor = surprise_predictor.create_knn_basic(name, params, **kwargs) 101 return TopK(predictor, kwargs['rated_items_filter']) 102 103 104def create_knn_baseline_als(name: str, params: Dict[str, Any], **kwargs) -> TopK: 105 """Create the KNNBaseline ALS recommender. 106 107 Args: 108 name: the name of the algorithm. 109 params: containing the following name-value pairs: 110 max_k(int): the maximum number of neighbors to take into account for aggregation. 111 min_k(int): the minimum number of neighbors to take into account for aggregation. 112 user_based(bool): whether similarities will be computed between users or between 113 items, this has a huge impact on the performance. 114 min_support(int): the minimum number of common items or users, depending on the 115 user_based parameter. 116 epochs(int): The number of iteration of the ALS procedure. 117 reg_i(int): the regularization parameter for items. 118 reg_u(int): The regularization parameter for items. 119 120 Returns: 121 the SurprisePredictor wrapper of KNNBaseline with method 'als' as a TopK recommender. 122 """ 123 predictor = surprise_predictor.create_knn_baseline_als(name, params, **kwargs) 124 return TopK(predictor, kwargs['rated_items_filter']) 125 126 127def create_knn_baseline_sgd(name: str, params: Dict[str, Any], **kwargs) -> TopK: 128 """Create the KNNBaseline SGD recommender. 129 130 Args: 131 name: the name of the algorithm. 132 params: containing the following name-value pairs: 133 max_k(int): the maximum number of neighbors to take into account for aggregation. 134 min_k(int): the minimum number of neighbors to take into account for aggregation. 135 user_based(bool): whether similarities will be computed between users or between 136 items, this has a huge impact on the performance. 137 min_support(int): the minimum number of common items or users, depending on the 138 user_based parameter. 139 shrinkage(int): shrinkage parameter to apply. 140 epochs(int): the number of iteration of the SGD procedure. 141 regularization(float): the regularization parameter 142 of the cost function that is optimized. 143 learning_rate(float): the learning rate of SGD. 144 145 Returns: 146 the SurprisePredictor wrapper of KNNBaseline with method 'sgd' as a TopK recommender. 147 """ 148 predictor = surprise_predictor.create_knn_baseline_sgd(name, params, **kwargs) 149 return TopK(predictor, kwargs['rated_items_filter']) 150 151 152def create_knn_with_means(name: str, params: Dict[str, Any], **kwargs) -> TopK: 153 """Create the KNNWithMeans recommender. 154 155 Args: 156 name: the name of the algorithm. 157 params: containing the following name-value pairs: 158 max_k(int): the maximum number of neighbors to take into account for aggregation. 159 min_k(int): the minimum number of neighbors to take into account for aggregation. 160 user_based(bool): whether similarities will be computed between users or between 161 items, this has a huge impact on the performance. 162 min_support(int): the minimum number of common items or users, depending on the 163 user_based parameter. 164 similarity(str): the name of the similarity to use ('MSD', 'cosine' or 'pearson'). 165 166 Returns: 167 the SurprisePredictor wrapper of KNNWithMeans as a TopK recommender. 168 """ 169 predictor = surprise_predictor.create_knn_with_means(name, params, **kwargs) 170 return TopK(predictor, kwargs['rated_items_filter']) 171 172 173def create_knn_with_zscore(name: str, params: Dict[str, Any], **kwargs) -> TopK: 174 """Create the KNNWithZScore recommender. 175 176 Args: 177 name: the name of the algorithm. 178 params: containing the following name-value pairs: 179 max_k(int): the maximum number of neighbors to take into account for aggregation. 180 min_k(int): the minimum number of neighbors to take into account for aggregation. 181 user_based(bool): whether similarities will be computed between users or between 182 items, this has a huge impact on the performance. 183 min_support(int): the minimum number of common items or users, depending on the 184 user_based parameter. 185 similarity(str): the name of the similarity to use ('MSD', 'cosine' or 'pearson'). 186 187 Returns: 188 the SurprisePredictor wrapper of KNNWithZScore as a TopK recommender. 189 """ 190 predictor = surprise_predictor.create_knn_with_zscore(name, params, **kwargs) 191 return TopK(predictor, kwargs['rated_items_filter']) 192 193 194def create_nmf(name: str, params: Dict[str, Any], **kwargs) -> TopK: 195 """Create the NMF recommender. 196 197 Args: 198 name: the name of the algorithm. 199 params: containing the following name-value pairs: 200 factors(int): the number of factors. 201 epochs(int): the number of iteration of the SGD procedure. 202 reg_pu(float): the regularization term for users. 203 reg_qi(float): the regularization term for items. 204 init_low(int): lower bound for random initialization of factors. 205 init_high(int): higher bound for random initialization of factors. 206 random_seed(int): the random seed or None for the current time as seed. 207 208 Returns: 209 the SurprisePredictor wrapper of NMF as a TopK recommender. 210 """ 211 predictor = surprise_predictor.create_nmf(name, params, **kwargs) 212 return TopK(predictor, kwargs['rated_items_filter']) 213 214 215def create_normal_predictor(name: str, params: Dict[str, Any], **kwargs) -> TopK: 216 """Create the NormalPredictor recommender. 217 218 Args: 219 name: the name of the algorithm. 220 params: there are no parameters for this algorithm. 221 222 Returns: 223 the SurprisePredictor wrapper of NormalPredictor as a TopK recommender. 224 """ 225 predictor = surprise_predictor.create_normal_predictor(name, params, **kwargs) 226 return TopK(predictor, kwargs['rated_items_filter']) 227 228 229def create_slope_one(name: str, params: Dict[str, Any], **kwargs) -> TopK: 230 """Create the SlopeOne recommender. 231 232 Args: 233 name: the name of the algorithm. 234 params: there are no parameters for this algorithm. 235 236 Returns: 237 the SurprisePredictor wrapper of SlopeOne as a TopK recommender. 238 """ 239 predictor = surprise_predictor.create_slope_one(name, params, **kwargs) 240 return TopK(predictor, kwargs['rated_items_filter']) 241 242 243def create_svd(name: str, params: Dict[str, Any], **kwargs) -> TopK: 244 """Create the SVD recommender. 245 246 Args: 247 name: the name of the algorithm. 248 params: containing the following name-value pairs: 249 factors(int): the number of factors. 250 epochs(int): the number of iteration of the SGD procedure. 251 biased(bool): whether to use baselines (or biases). 252 init_mean(int): the mean of the normal distribution for factor vectors initialization. 253 init_std_dev(float): the standard deviation of the normal distribution for 254 factor vectors initialization. 255 learning_rate(float): the learning rate for users and items. 256 regularization(float): the regularization term for users and items. 257 random_seed(int): the random seed or None for the current time as seed. 258 259 Returns: 260 the SurprisePredictor wrapper of SVD as a TopK recommender. 261 """ 262 predictor = surprise_predictor.create_svd(name, params, **kwargs) 263 return TopK(predictor, kwargs['rated_items_filter']) 264 265 266def create_svd_pp(name: str, params: Dict[str, Any], **kwargs) -> TopK: 267 """Create the SVDpp recommender. 268 269 Args: 270 name: the name of the algorithm. 271 params: containing the following name-value pairs: 272 factors(int): the number of factors. 273 epochs(int): the number of iteration of the SGD procedure. 274 init_mean(int): the mean of the normal distribution for factor vectors initialization. 275 init_std_dev(float): the standard deviation of the normal distribution for 276 factor vectors initialization. 277 learning_rate(float): the learning rate for users and items. 278 regularization(float): the regularization term for users and items. 279 random_seed(int): the random seed or None for the current time as seed. 280 281 Returns: 282 the SurprisePredictor wrapper of SVDpp as a TopK recommender. 283 """ 284 predictor = surprise_predictor.create_svd_pp(name, params, **kwargs) 285 return TopK(predictor, kwargs['rated_items_filter'])
31def create_baseline_only_als(name: str, params: Dict[str, Any], **kwargs) -> TopK: 32 """Create the BaselineOnly ALS recommender. 33 34 Args: 35 name: the name of the algorithm. 36 params: containing the following name-value pairs: 37 epochs(int): The number of iteration of the ALS procedure. 38 reg_i(int): the regularization parameter for items. 39 reg_u(int): The regularization parameter for items. 40 41 Returns: 42 the SurprisePredictor wrapper of BaselineOnly with method 'als' as a TopK recommender. 43 """ 44 predictor = surprise_predictor.create_baseline_only_als(name, params, **kwargs) 45 return TopK(predictor, kwargs['rated_items_filter'])
Create the BaselineOnly ALS recommender.
Args: name: the name of the algorithm. params: containing the following name-value pairs: epochs(int): The number of iteration of the ALS procedure. reg_i(int): the regularization parameter for items. reg_u(int): The regularization parameter for items.
Returns: the SurprisePredictor wrapper of BaselineOnly with method 'als' as a TopK recommender.
48def create_baseline_only_sgd(name: str, params: Dict[str, Any], **kwargs) -> TopK: 49 """Create the BaselineOnly SGD recommender. 50 51 Args: 52 name: the name of the algorithm. 53 params: containing the following name-value pairs: 54 epochs(int): the number of iteration of the SGD procedure. 55 regularization(float): the regularization parameter 56 of the cost function that is optimized. 57 learning_rate(float): the learning rate of SGD. 58 59 Returns: 60 the SurprisePredictor wrapper of BaselineOnly with method 'sgd' as a TopK recommender. 61 """ 62 predictor = surprise_predictor.create_baseline_only_sgd(name, params, **kwargs) 63 return TopK(predictor, kwargs['rated_items_filter'])
Create the BaselineOnly SGD recommender.
Args: name: the name of the algorithm. params: containing the following name-value pairs: epochs(int): the number of iteration of the SGD procedure. regularization(float): the regularization parameter of the cost function that is optimized. learning_rate(float): the learning rate of SGD.
Returns: the SurprisePredictor wrapper of BaselineOnly with method 'sgd' as a TopK recommender.
66def create_co_clustering(name: str, params: Dict[str, Any], **kwargs) -> TopK: 67 """Create the CoClustering recommender. 68 69 Args: 70 name: the name of the algorithm. 71 params: containing the following name-value pairs: 72 epochs(int): number of iteration of the optimization loop. 73 user_clusters(int): number of user clusters. 74 item_clusters(int): number of item clusters. 75 random_seed(int): the random seed or None for the current time as seed. 76 77 Returns: 78 the SurprisePredictor wrapper of CoClustering as a TopK recommender. 79 """ 80 predictor = surprise_predictor.create_co_clustering(name, params, **kwargs) 81 return TopK(predictor, kwargs['rated_items_filter'])
Create the CoClustering recommender.
Args: name: the name of the algorithm. params: containing the following name-value pairs: epochs(int): number of iteration of the optimization loop. user_clusters(int): number of user clusters. item_clusters(int): number of item clusters. random_seed(int): the random seed or None for the current time as seed.
Returns: the SurprisePredictor wrapper of CoClustering as a TopK recommender.
84def create_knn_basic(name: str, params: Dict[str, Any], **kwargs) -> TopK: 85 """Create the KNNBasic recommender. 86 87 Args: 88 name: the name of the algorithm. 89 params: containing the following name-value pairs: 90 max_k(int): the maximum number of neighbors to take into account for aggregation. 91 min_k(int): the minimum number of neighbors to take into account for aggregation. 92 user_based(bool): whether similarities will be computed between users or between 93 items, this has a huge impact on the performance. 94 min_support(int): the minimum number of common items or users, depending on the 95 user_based parameter. 96 similarity(str): the name of the similarity to use ('MSD', 'cosine' or 'pearson'). 97 98 Returns: 99 the SurprisePredictor wrapper of KNNBasic as a TopK recommender. 100 """ 101 predictor = surprise_predictor.create_knn_basic(name, params, **kwargs) 102 return TopK(predictor, kwargs['rated_items_filter'])
Create the KNNBasic recommender.
Args: name: the name of the algorithm. params: containing the following name-value pairs: max_k(int): the maximum number of neighbors to take into account for aggregation. min_k(int): the minimum number of neighbors to take into account for aggregation. user_based(bool): whether similarities will be computed between users or between items, this has a huge impact on the performance. min_support(int): the minimum number of common items or users, depending on the user_based parameter. similarity(str): the name of the similarity to use ('MSD', 'cosine' or 'pearson').
Returns: the SurprisePredictor wrapper of KNNBasic as a TopK recommender.
105def create_knn_baseline_als(name: str, params: Dict[str, Any], **kwargs) -> TopK: 106 """Create the KNNBaseline ALS recommender. 107 108 Args: 109 name: the name of the algorithm. 110 params: containing the following name-value pairs: 111 max_k(int): the maximum number of neighbors to take into account for aggregation. 112 min_k(int): the minimum number of neighbors to take into account for aggregation. 113 user_based(bool): whether similarities will be computed between users or between 114 items, this has a huge impact on the performance. 115 min_support(int): the minimum number of common items or users, depending on the 116 user_based parameter. 117 epochs(int): The number of iteration of the ALS procedure. 118 reg_i(int): the regularization parameter for items. 119 reg_u(int): The regularization parameter for items. 120 121 Returns: 122 the SurprisePredictor wrapper of KNNBaseline with method 'als' as a TopK recommender. 123 """ 124 predictor = surprise_predictor.create_knn_baseline_als(name, params, **kwargs) 125 return TopK(predictor, kwargs['rated_items_filter'])
Create the KNNBaseline ALS recommender.
Args: name: the name of the algorithm. params: containing the following name-value pairs: max_k(int): the maximum number of neighbors to take into account for aggregation. min_k(int): the minimum number of neighbors to take into account for aggregation. user_based(bool): whether similarities will be computed between users or between items, this has a huge impact on the performance. min_support(int): the minimum number of common items or users, depending on the user_based parameter. epochs(int): The number of iteration of the ALS procedure. reg_i(int): the regularization parameter for items. reg_u(int): The regularization parameter for items.
Returns: the SurprisePredictor wrapper of KNNBaseline with method 'als' as a TopK recommender.
128def create_knn_baseline_sgd(name: str, params: Dict[str, Any], **kwargs) -> TopK: 129 """Create the KNNBaseline SGD recommender. 130 131 Args: 132 name: the name of the algorithm. 133 params: containing the following name-value pairs: 134 max_k(int): the maximum number of neighbors to take into account for aggregation. 135 min_k(int): the minimum number of neighbors to take into account for aggregation. 136 user_based(bool): whether similarities will be computed between users or between 137 items, this has a huge impact on the performance. 138 min_support(int): the minimum number of common items or users, depending on the 139 user_based parameter. 140 shrinkage(int): shrinkage parameter to apply. 141 epochs(int): the number of iteration of the SGD procedure. 142 regularization(float): the regularization parameter 143 of the cost function that is optimized. 144 learning_rate(float): the learning rate of SGD. 145 146 Returns: 147 the SurprisePredictor wrapper of KNNBaseline with method 'sgd' as a TopK recommender. 148 """ 149 predictor = surprise_predictor.create_knn_baseline_sgd(name, params, **kwargs) 150 return TopK(predictor, kwargs['rated_items_filter'])
Create the KNNBaseline SGD recommender.
Args: name: the name of the algorithm. params: containing the following name-value pairs: max_k(int): the maximum number of neighbors to take into account for aggregation. min_k(int): the minimum number of neighbors to take into account for aggregation. user_based(bool): whether similarities will be computed between users or between items, this has a huge impact on the performance. min_support(int): the minimum number of common items or users, depending on the user_based parameter. shrinkage(int): shrinkage parameter to apply. epochs(int): the number of iteration of the SGD procedure. regularization(float): the regularization parameter of the cost function that is optimized. learning_rate(float): the learning rate of SGD.
Returns: the SurprisePredictor wrapper of KNNBaseline with method 'sgd' as a TopK recommender.
153def create_knn_with_means(name: str, params: Dict[str, Any], **kwargs) -> TopK: 154 """Create the KNNWithMeans recommender. 155 156 Args: 157 name: the name of the algorithm. 158 params: containing the following name-value pairs: 159 max_k(int): the maximum number of neighbors to take into account for aggregation. 160 min_k(int): the minimum number of neighbors to take into account for aggregation. 161 user_based(bool): whether similarities will be computed between users or between 162 items, this has a huge impact on the performance. 163 min_support(int): the minimum number of common items or users, depending on the 164 user_based parameter. 165 similarity(str): the name of the similarity to use ('MSD', 'cosine' or 'pearson'). 166 167 Returns: 168 the SurprisePredictor wrapper of KNNWithMeans as a TopK recommender. 169 """ 170 predictor = surprise_predictor.create_knn_with_means(name, params, **kwargs) 171 return TopK(predictor, kwargs['rated_items_filter'])
Create the KNNWithMeans recommender.
Args: name: the name of the algorithm. params: containing the following name-value pairs: max_k(int): the maximum number of neighbors to take into account for aggregation. min_k(int): the minimum number of neighbors to take into account for aggregation. user_based(bool): whether similarities will be computed between users or between items, this has a huge impact on the performance. min_support(int): the minimum number of common items or users, depending on the user_based parameter. similarity(str): the name of the similarity to use ('MSD', 'cosine' or 'pearson').
Returns: the SurprisePredictor wrapper of KNNWithMeans as a TopK recommender.
174def create_knn_with_zscore(name: str, params: Dict[str, Any], **kwargs) -> TopK: 175 """Create the KNNWithZScore recommender. 176 177 Args: 178 name: the name of the algorithm. 179 params: containing the following name-value pairs: 180 max_k(int): the maximum number of neighbors to take into account for aggregation. 181 min_k(int): the minimum number of neighbors to take into account for aggregation. 182 user_based(bool): whether similarities will be computed between users or between 183 items, this has a huge impact on the performance. 184 min_support(int): the minimum number of common items or users, depending on the 185 user_based parameter. 186 similarity(str): the name of the similarity to use ('MSD', 'cosine' or 'pearson'). 187 188 Returns: 189 the SurprisePredictor wrapper of KNNWithZScore as a TopK recommender. 190 """ 191 predictor = surprise_predictor.create_knn_with_zscore(name, params, **kwargs) 192 return TopK(predictor, kwargs['rated_items_filter'])
Create the KNNWithZScore recommender.
Args: name: the name of the algorithm. params: containing the following name-value pairs: max_k(int): the maximum number of neighbors to take into account for aggregation. min_k(int): the minimum number of neighbors to take into account for aggregation. user_based(bool): whether similarities will be computed between users or between items, this has a huge impact on the performance. min_support(int): the minimum number of common items or users, depending on the user_based parameter. similarity(str): the name of the similarity to use ('MSD', 'cosine' or 'pearson').
Returns: the SurprisePredictor wrapper of KNNWithZScore as a TopK recommender.
195def create_nmf(name: str, params: Dict[str, Any], **kwargs) -> TopK: 196 """Create the NMF recommender. 197 198 Args: 199 name: the name of the algorithm. 200 params: containing the following name-value pairs: 201 factors(int): the number of factors. 202 epochs(int): the number of iteration of the SGD procedure. 203 reg_pu(float): the regularization term for users. 204 reg_qi(float): the regularization term for items. 205 init_low(int): lower bound for random initialization of factors. 206 init_high(int): higher bound for random initialization of factors. 207 random_seed(int): the random seed or None for the current time as seed. 208 209 Returns: 210 the SurprisePredictor wrapper of NMF as a TopK recommender. 211 """ 212 predictor = surprise_predictor.create_nmf(name, params, **kwargs) 213 return TopK(predictor, kwargs['rated_items_filter'])
Create the NMF recommender.
Args: name: the name of the algorithm. params: containing the following name-value pairs: factors(int): the number of factors. epochs(int): the number of iteration of the SGD procedure. reg_pu(float): the regularization term for users. reg_qi(float): the regularization term for items. init_low(int): lower bound for random initialization of factors. init_high(int): higher bound for random initialization of factors. random_seed(int): the random seed or None for the current time as seed.
Returns: the SurprisePredictor wrapper of NMF as a TopK recommender.
216def create_normal_predictor(name: str, params: Dict[str, Any], **kwargs) -> TopK: 217 """Create the NormalPredictor recommender. 218 219 Args: 220 name: the name of the algorithm. 221 params: there are no parameters for this algorithm. 222 223 Returns: 224 the SurprisePredictor wrapper of NormalPredictor as a TopK recommender. 225 """ 226 predictor = surprise_predictor.create_normal_predictor(name, params, **kwargs) 227 return TopK(predictor, kwargs['rated_items_filter'])
Create the NormalPredictor recommender.
Args: name: the name of the algorithm. params: there are no parameters for this algorithm.
Returns: the SurprisePredictor wrapper of NormalPredictor as a TopK recommender.
230def create_slope_one(name: str, params: Dict[str, Any], **kwargs) -> TopK: 231 """Create the SlopeOne recommender. 232 233 Args: 234 name: the name of the algorithm. 235 params: there are no parameters for this algorithm. 236 237 Returns: 238 the SurprisePredictor wrapper of SlopeOne as a TopK recommender. 239 """ 240 predictor = surprise_predictor.create_slope_one(name, params, **kwargs) 241 return TopK(predictor, kwargs['rated_items_filter'])
Create the SlopeOne recommender.
Args: name: the name of the algorithm. params: there are no parameters for this algorithm.
Returns: the SurprisePredictor wrapper of SlopeOne as a TopK recommender.
244def create_svd(name: str, params: Dict[str, Any], **kwargs) -> TopK: 245 """Create the SVD recommender. 246 247 Args: 248 name: the name of the algorithm. 249 params: containing the following name-value pairs: 250 factors(int): the number of factors. 251 epochs(int): the number of iteration of the SGD procedure. 252 biased(bool): whether to use baselines (or biases). 253 init_mean(int): the mean of the normal distribution for factor vectors initialization. 254 init_std_dev(float): the standard deviation of the normal distribution for 255 factor vectors initialization. 256 learning_rate(float): the learning rate for users and items. 257 regularization(float): the regularization term for users and items. 258 random_seed(int): the random seed or None for the current time as seed. 259 260 Returns: 261 the SurprisePredictor wrapper of SVD as a TopK recommender. 262 """ 263 predictor = surprise_predictor.create_svd(name, params, **kwargs) 264 return TopK(predictor, kwargs['rated_items_filter'])
Create the SVD recommender.
Args: name: the name of the algorithm. params: containing the following name-value pairs: factors(int): the number of factors. epochs(int): the number of iteration of the SGD procedure. biased(bool): whether to use baselines (or biases). init_mean(int): the mean of the normal distribution for factor vectors initialization. init_std_dev(float): the standard deviation of the normal distribution for factor vectors initialization. learning_rate(float): the learning rate for users and items. regularization(float): the regularization term for users and items. random_seed(int): the random seed or None for the current time as seed.
Returns: the SurprisePredictor wrapper of SVD as a TopK recommender.
267def create_svd_pp(name: str, params: Dict[str, Any], **kwargs) -> TopK: 268 """Create the SVDpp recommender. 269 270 Args: 271 name: the name of the algorithm. 272 params: containing the following name-value pairs: 273 factors(int): the number of factors. 274 epochs(int): the number of iteration of the SGD procedure. 275 init_mean(int): the mean of the normal distribution for factor vectors initialization. 276 init_std_dev(float): the standard deviation of the normal distribution for 277 factor vectors initialization. 278 learning_rate(float): the learning rate for users and items. 279 regularization(float): the regularization term for users and items. 280 random_seed(int): the random seed or None for the current time as seed. 281 282 Returns: 283 the SurprisePredictor wrapper of SVDpp as a TopK recommender. 284 """ 285 predictor = surprise_predictor.create_svd_pp(name, params, **kwargs) 286 return TopK(predictor, kwargs['rated_items_filter'])
Create the SVDpp recommender.
Args: name: the name of the algorithm. params: containing the following name-value pairs: factors(int): the number of factors. epochs(int): the number of iteration of the SGD procedure. init_mean(int): the mean of the normal distribution for factor vectors initialization. init_std_dev(float): the standard deviation of the normal distribution for factor vectors initialization. learning_rate(float): the learning rate for users and items. regularization(float): the regularization term for users and items. random_seed(int): the random seed or None for the current time as seed.
Returns: the SurprisePredictor wrapper of SVDpp as a TopK recommender.