models¶
Probabilistic Collaborative Representation Learning (PCRL)¶
@author: Aghiles Salah <asalah@smu.edu.sg>
-
class
cornac.models.pcrl.recom_pcrl.
PCRL
(k=100, z_dims=[300], max_iter=300, batch_size=300, learning_rate=0.001, aux_info=None, name='pcrl', trainable=True, w_determinist=True, init_params={'G_r': None, 'G_s': None, 'L_r': None, 'L_s': None})[source]¶ Probabilistic Collaborative Representation Learning.
Parameters: - k (int, optional, default: 100) – The dimension of the latent factors.
- z_dims (Numpy 1d array, optional, default: [300]) – The dimensions of the hidden intermdiate layers ‘z’ in the order [dim(z_L), …,dim(z_1)], please refer to Figure 1 in the orginal paper for more details.
- max_iter (int, optional, default: 300) – Maximum number of iterations (number of epochs) for variational PCRL.
- batch_size (int, optional, default: 300) – The batch size for SGD.
- learning_rate (float, optional, default: 0.001) – The learning rate for SGD.
- aux_info (csc sparse matrix, required) – The item auxiliary information matrix, item-context in the PCRL’s paper, in the scipy csc sparse format.
- name (string, optional, default: 'PCRL') – The name of the recommender model.
- trainable (boolean, optional, default: True) – When False, the model is not trained and Cornac assumes that the model already pre-trained (Theta, Beta and Xi are not None).
- w_determinist (boolean, optional, default: True) – When True, determinist wheights “W” are used for the generator network, otherwise “W” is stochastic as in the original paper.
- init_params (dictionary, optional, default: {'G_s':None, 'G_r':None, 'L_s':None, 'L_r':None}) – List of initial parameters, e.g., init_params = {‘G_s’:G_s, ‘G_r’:G_r, ‘L_s’:L_s, ‘L_r’:L_r}, where G_s and G_r are of type csc_matrix or np.array with the same shape as Theta, see below). They represent respectively the “shape” and “rate” parameters of Gamma distribution over Theta. It is the same for L_s, L_r and Beta.
- Theta (csc_matrix, shape (n_users,k)) – The expected user latent factors.
- Beta (csc_matrix, shape (n_items,k)) – The expected item latent factors.
References
- Salah, Aghiles, and Hady W. Lauw. Probabilistic Collaborative Representation Learning for Personalized Item Recommendation. In UAI 2018.
-
fit
(X)[source]¶ Fit the model to observations.
Parameters: X (scipy sparse matrix, required) – the user-item preference matrix (traning data), in a scipy sparse format (e.g., csc_matrix).
-
rank
(user_index, known_items=None)[source]¶ Rank all test items for a given user.
Parameters: - user_index (int, required) – The index of the user for whom to perform item raking.
- known_items (1d array, optional, default: None) – A list of item indices already known by the user
Returns: Array of item indices sorted (in decreasing order) relative to some user preference scores.
Return type: Numpy 1d array
-
score
(user_index, item_indexes=None)[source]¶ Predict the scores/ratings of a user for a list of items.
Parameters: - user_index (int, required) – The index of the user for whom to perform score predictions.
- item_indexes (1d array, optional, default: None) – A list of item indexes for which to predict the rating score. When “None”, score prediction is performed for all test items of the given user.
Returns: Array containing the predicted values for the items of interest
Return type: Numpy 1d array
Collaborative Context Poisson Factorization (C2PF)¶
@author: Aghiles Salah <asalah@smu.edu.sg>
-
class
cornac.models.c2pf.recom_c2pf.
C2PF
(k=100, max_iter=100, aux_info=None, variant='c2pf', name=None, trainable=True, init_params={'G_r': None, 'G_s': None, 'L2_r': None, 'L2_s': None, 'L3_r': None, 'L3_s': None, 'L_r': None, 'L_s': None})[source]¶ Collaborative Context Poisson Factorization.
Parameters: - k (int, optional, default: 100) – The dimension of the latent factors.
- max_iter (int, optional, default: 100) – Maximum number of iterations for variational C2PF.
- aux_info (array, required, shape (n_context_items,3)) – The item-context matrix, noted C in the original paper, in the triplet sparse format: (row_id, col_id, value).
- variant (string, optional, default: 'c2pf') – C2pf’s variant: c2pf: ‘c2pf’, ‘tc2pf’ (tied-c2pf) or ‘rc2pf’ (reduced-c2pf). Please refer to the original paper for details.
- name (string, optional, default: None) – The name of the recommender model. If None, then “variant” is used as the default name of the model.
- trainable (boolean, optional, default: True) – When False, the model is not trained and Cornac assumes that the model already pre-trained (Theta, Beta and Xi are not None).
- init_params (dictionary, optional, default: {'G_s':None, 'G_r':None, 'L_s':None, 'L_r':None, 'L2_s':None, 'L2_r':None, 'L3_s':None, 'L3_r':None}) – List of initial parameters, e.g., init_params = {‘G_s’:G_s, ‘G_r’:G_r, ‘L_s’:L_s, ‘L_r’:L_r, ‘L2_s’:L2_s, ‘L2_r’:L2_r, ‘L3_s’:L3_s, ‘L3_r’:L3_r}, where G_s and G_r are of type csc_matrix or np.array with the same shape as Theta, see below). They represent respectively the “shape” and “rate” parameters of Gamma distribution over Theta. It is the same for L_s, L_r and Beta, L2_s, L2_r and Xi, L3_s, L3_r and Kappa.
- Theta (csc_matrix, shape (n_users,k)) – The expected user latent factors.
- Beta (csc_matrix, shape (n_items,k)) – The expected item latent factors.
- Xi (csc_matrix, shape (n_items,k)) – The expected context item latent factors multiplied by context effects Kappa, please refer to the paper below for details.
References
- Salah, Aghiles, and Hady W. Lauw. A Bayesian Latent Variable Model of User Preferences with Item Context. In IJCAI, pp. 2667-2674. 2018.
-
fit
(X)[source]¶ Fit the model to observations.
Parameters: X (scipy sparse matrix, required) – the user-item preference matrix (traning data), in a scipy sparse format (e.g., csc_matrix).
-
rank
(user_index, known_items=None)[source]¶ Rank all test items for a given user.
Parameters: - user_index (int, required) – The index of the user for whom to perform item raking.
- known_items (1d array, optional, default: None) – A list of item indices already known by the user
Returns: Array of item indices sorted (in decreasing order) relative to some user preference scores.
Return type: Numpy 1d array
-
score
(user_index, item_indexes=None)[source]¶ Predict the scores/ratings of a user for a list of items.
Parameters: - user_index (int, required) – The index of the user for whom to perform score predictions.
- item_indexes (1d array, optional, default: None) – A list of item indexes for which to predict the rating score. When “None”, score prediction is performed for all test items of the given user.
Returns: Array containing the predicted values for the items of interest
Return type: Numpy 1d array
Indexable Bayesian Personalized Ranking (IBPR)¶
@author: Dung D. Le (Andrew) <ddle.2015@smu.edu.sg>
-
class
cornac.models.ibpr.recom_ibpr.
IBPR
(k=20, max_iter=100, learning_rate=0.05, lamda=0.001, batch_size=100, name='ibpr', trainable=True, init_params=None)[source]¶ Indexable Bayesian Personalized Ranking.
Parameters: - k (int, optional, default: 20) – The dimension of the latent factors.
- max_iter (int, optional, default: 100) – Maximum number of iterations or the number of epochs for SGD.
- learning_rate (float, optional, default: 0.05) – The learning rate for SGD.
- lamda (float, optional, default: 0.001) – The regularization parameter.
- batch_size (int, optional, default: 100) – The batch size for SGD.
- name (string, optional, default: 'IBRP') – The name of the recommender model.
- trainable (boolean, optional, default: True) – When False, the model is not trained and Cornac assumes that the model already pre-trained (U and V are not None).
- init_params (dictionary, optional, default: None) – List of initial parameters, e.g., init_params = {‘U’:U, ‘V’:V} please see below the definition of U and V.
- U (csc_matrix, shape (n_users,k)) – The user latent factors, optional initialization via init_params.
- V (csc_matrix, shape (n_items,k)) – The item latent factors, optional initialization via init_params.
References
- Le, D. D., & Lauw, H. W. (2017, November). Indexable Bayesian personalized ranking for efficient top-k recommendation. In Proceedings of the 2017 ACM on Conference on Information and Knowledge Management (pp. 1389-1398). ACM.
-
fit
(X)[source]¶ Fit the model to observations.
Parameters: X (scipy sparse matrix, required) – the user-item preference matrix (traning data), in a scipy sparse format (e.g., csc_matrix).
-
rank
(user_index, known_items=None)[source]¶ Rank all test items for a given user.
Parameters: - user_index (int, required) – The index of the user for whom to perform item raking.
- known_items (1d array, optional, default: None) – A list of item indices already known by the user
Returns: Array of item indices sorted (in decreasing order) relative to some user preference scores.
Return type: Numpy 1d array
-
score
(user_index, item_indexes=None)[source]¶ Predict the scores/ratings of a user for a list of items.
Parameters: - user_index (int, required) – The index of the user for whom to perform score predictions.
- item_indexes (1d array, optional, default: None) – A list of item indexes for which to predict the rating score. When “None”, score prediction is performed for all test items of the given user.
Returns: Array containing the predicted values for the items of interest
Return type: Numpy 1d array
Online Indexable Bayesian Personalized Ranking (OIBPR)¶
@author: Dung D. Le (Andrew) <ddle.2015@smu.edu.sg>
-
class
cornac.models.online_ibpr.recom_online_ibpr.
OnlineIBPR
(k=20, max_iter=100, learning_rate=0.05, lamda=0.001, batch_size=100, name='online_ibpr', trainable=True, init_params=None)[source]¶ Online Indexable Bayesian Personalized Ranking.
Parameters: - k (int, optional, default: 20) – The dimension of the latent factors.
- max_iter (int, optional, default: 100) – Maximum number of iterations or the number of epochs for SGD.
- learning_rate (float, optional, default: 0.05) – The learning rate for SGD.
- lamda (float, optional, default: 0.001) – The regularization parameter.
- batch_size (int, optional, default: 100) – The batch size for SGD.
- name (string, optional, default: 'IBRP') – The name of the recommender model.
- trainable (boolean, optional, default: True) – When False, the model is not trained and Cornac assumes that the model already pre-trained (U and V are not None).
- init_params (dictionary, optional, default: None) – List of initial parameters, e.g., init_params = {‘U’:U, ‘V’:V} please see below the definition of U and V.
- U (csc_matrix, shape (n_users,k)) – The user latent factors, optional initialization via init_params.
- V (csc_matrix, shape (n_items,k)) – The item latent factors, optional initialization via init_params.
References
- Le, D. D., & Lauw, H. W. (2017, November). Indexable Bayesian personalized ranking for efficient top-k recommendation. In Proceedings of the 2017 ACM on Conference on Information and Knowledge Management (pp. 1389-1398). ACM.
-
fit
(triplets)[source]¶ Fit the model to observations.
Parameters: triplets (collections of user's ordinal triplets (u, i, j) indicating u prefers i to j) –
-
rank
(user_index, known_items=None)[source]¶ Rank all test items for a given user.
Parameters: - user_index (int, required) – The index of the user for whom to perform item raking.
- known_items (1d array, optional, default: None) – A list of item indices already known by the user
Returns: Array of item indices sorted (in decreasing order) relative to some user preference scores.
Return type: Numpy 1d array
-
score
(user_index, item_indexes=None)[source]¶ Predict the scores/ratings of a user for a list of items.
Parameters: - user_index (int, required) – The index of the user for whom to perform score predictions.
- item_indexes (1d array, optional, default: None) – A list of item indexes for which to predict the rating score. When “None”, score prediction is performed for all test items of the given user.
Returns: Array containing the predicted values for the items of interest
Return type: Numpy 1d array
Collaborative Ordinal Embedding (COE)¶
@author: Dung D. Le (Andrew) <ddle.2015@smu.edu.sg>
-
class
cornac.models.coe.recom_coe.
COE
(k=20, max_iter=100, learning_rate=0.05, lamda=0.001, batch_size=1000, name='coe', trainable=True, init_params=None)[source]¶ Collaborative Ordinal Embedding.
Parameters: - k (int, optional, default: 20) – The dimension of the latent factors.
- max_iter (int, optional, default: 100) – Maximum number of iterations or the number of epochs for SGD.
- learning_rate (float, optional, default: 0.05) – The learning rate for SGD.
- lamda (float, optional, default: 0.001) – The regularization parameter.
- batch_size (int, optional, default: 100) – The batch size for SGD.
- name (string, optional, default: 'IBRP') – The name of the recommender model.
- trainable (boolean, optional, default: True) – When False, the model is not trained and Cornac assumes that the model already pre-trained (U and V are not None).
- init_params (dictionary, optional, default: None) – List of initial parameters, e.g., init_params = {‘U’:U, ‘V’:V} please see below the definition of U and V.
- U (csc_matrix, shape (n_users,k)) – The user latent factors, optional initialization via init_params.
- V (csc_matrix, shape (n_items,k)) – The item latent factors, optional initialization via init_params.
References
- Le, D. D., & Lauw, H. W. (2016, June). Euclidean co-embedding of ordinal data for multi-type visualization. In Proceedings of the 2016 SIAM International Conference on Data Mining (pp. 396-404). Society for Industrial and Applied Mathematics.
-
fit
(X)[source]¶ Fit the model to observations.
Parameters: X (scipy sparse matrix, required) – the user-item preference matrix (traning data), in a scipy sparse format (e.g., csc_matrix).
-
rank
(user_index, known_items=None)[source]¶ Rank all test items for a given user.
Parameters: - user_index (int, required) – The index of the user for whom to perform item raking.
- known_items (1d array, optional, default: None) – A list of item indices already known by the user
Returns: Array of item indices sorted (in decreasing order) relative to some user preference scores.
Return type: Numpy 1d array
-
score
(user_index, item_indexes=None)[source]¶ Predict the scores/ratings of a user for a list of items.
Parameters: - user_index (int, required) – The index of the user for whom to perform score predictions.
- item_indexes (1d array, optional, default: None) – A list of item indexes for which to predict the rating score. When “None”, score prediction is performed for all test items of the given user.
Returns: Array containing the predicted values for the items of interest
Return type: Numpy 1d array
Visual Bayesian Personalized Ranking (VBPR)¶
@author: Guo Jingyao
-
class
cornac.models.vbpr.recom_vbpr.
VBPR
(k=10, d=10, max_iter=100, aux_info=None, learning_rate=0.001, lamda=0.01, batch_size=100, name='vbpr', trainable=True, init_params=None)[source]¶ Visual Bayesian Personalized Ranking.
Parameters: - k (int, optional, default: 5) – The dimension of the latent factors.
- d (int, optional, default: 5) – The dimension of the latent factors.
- max_iter (int, optional, default: 100) – Maximum number of iterations or the number of epochs for SGD.
- shape (n_items, feature dimension), optional, default (aux_info:ndarray,) – Image features of items
- learning_rate (float, optional, default: 0.001) – The learning rate for SGD.
- lamda (float, optional, default: 0.01) – The regularization parameter.
- batch_size (int, optional, default: 100) – The batch size for SGD.
- name (string, optional, default: 'BRP') – The name of the recommender model.
- trainable (boolean, optional, default: True) – When False, the model is not trained and Cornac assumes that the model already pre-trained (U and V are not None).
- init_params (dictionary, optional, default: None) – List of initial parameters, e.g., init_params = {‘U’:U, ‘V’:V} please see below the definition of U and V.
- U (ndarray, shape (n_users,k)) – The user latent factors, optional initialization via init_params.
- V (ndarray, shape (n_items,k)) – The item latent factors, optional initialization via init_params.
- E (ndarray, shape (d, feature dimension)) – The matrix embedding deep CNN feature, optional initialization via init_params.
- Ue (ndarray, shape (n_users, d)) – The visual factors of users, optional initialization via init_params.
References
- HE, Ruining et MCAULEY, Julian. VBPR: Visual Bayesian Personalized Ranking from Implicit Feedback. In : AAAI. 2016. p. 144-150.
-
fit
(X)[source]¶ Fit the model to observations.
Parameters: X (scipy sparse matrix, required) – the user-item preference matrix (traning data), in a scipy sparse format (e.g., csc_matrix).
-
rank
(user_index, known_items=None)[source]¶ Rank all test items for a given user.
Parameters: - user_index (int, required) – The index of the user for whom to perform item raking.
- known_items (1d array, optional, default: None) – A list of item indices already known by the user
Returns: Array of item indices sorted (in decreasing order) relative to some user preference scores.
Return type: Numpy 1d array
-
score
(user_index, item_indexes=None)[source]¶ Predict the scores/ratings of a user for a list of items.
Parameters: - user_index (int, required) – The index of the user for whom to perform score predictions.
- item_indexes (1d array, optional, default: None) – A list of item indexes for which to predict the rating score. When “None”, score prediction is performed for all test items of the given user.
Returns: Array containing the predicted values for the items of interest
Return type: Numpy 1d array
Spherical k-means (Skmeans)¶
@author: Aghiles Salah <asalah@smu.edu.sg>
-
class
cornac.models.skm.recom_skmeans.
SKMeans
(k=5, max_iter=100, name='Skmeans', trainable=True, tol=1e-06, verbose=True, init_par=None)[source]¶ Spherical k-means based recommender.
Parameters: - k (int, optional, default: 5) – The number of clusters.
- max_iter (int, optional, default: 100) – Maximum number of iterations.
- name (string, optional, default: 'Skmeans') – The name of the recommender model.
- trainable (boolean, optional, default: True) – When False, the model is not trained and Cornac assumes that the model is already trained.
- tol (float, optional, default: 1e-6) – Relative tolerance with regards to skmeans’ criterion to declare convergence.
- verbose (boolean, optional, default: True) – When True, the skmeans criterion (likelihood) is displayed after each iteration.
- init_par (numpy 1d array, optional, default: None) – The initial object parition, 1d array contaning the cluster label (int type starting from 0) of each object (user). If par = None, then skmeans is initialized randomly.
- centroids (csc_matrix, shape (k,n_users)) – The maxtrix of cluster centroids.
References
- Salah, Aghiles, Nicoleta Rogovschi, and Mohamed Nadif. “A dynamic collaborative filtering system via a weighted clustering approach.” Neurocomputing 175 (2016): 206-215.
-
fit
(X)[source]¶ Fit the model to observations.
Parameters: X (scipy sparse matrix, required) – the user-item preference matrix (traning data), in a scipy sparse format (e.g., csc_matrix).
-
rank
(user_index, known_items=None)[source]¶ Rank all test items for a given user.
Parameters: - user_index (int, required) – The index of the user for whom to perform item raking.
- known_items (1d array, optional, default: None) – A list of item indices already known by the user
Returns: Array of item indices sorted (in decreasing order) relative to some user preference scores.
Return type: Numpy 1d array
-
score
(user_index, item_indexes=None)[source]¶ Predict the scores/ratings of a user for a list of items.
Parameters: - user_index (int, required) – The index of the user for whom to perform score predictions.
- item_indexes (1d array, optional, default: None) – A list of item indexes for which to predict the rating score. When “None”, score prediction is performed for all test items of the given user.
Returns: Array containing the predicted values for the items of interest
Return type: Numpy 1d array
Hierarchical Poisson Factorization (HPF)¶
@author: Aghiles Salah <asalah@smu.edu.sg>
-
class
cornac.models.hpf.recom_hpf.
HPF
(k=5, max_iter=100, name='HPF', trainable=True, init_params={'G_r': None, 'G_s': None, 'L_r': None, 'L_s': None})[source]¶ Hierarchical Poisson Factorization.
Parameters: - k (int, optional, default: 5) – The dimension of the latent factors.
- max_iter (int, optional, default: 100) – Maximum number of iterations.
- name (string, optional, default: 'HPF') – The name of the recommender model.
- trainable (boolean, optional, default: True) – When False, the model is not trained and Cornac assumes that the model is already pre-trained (Theta and Beta are not None).
- init_params (dictionary, optional, default: {'G_s':None, 'G_r':None, 'L_s':None, 'L_r':None}) – List of initial parameters, e.g., init_params = {‘G_s’:G_s, ‘G_r’:G_r, ‘L_s’:L_s, ‘L_r’:L_r}, where G_s and G_r are of type csc_matrix or np.array with the same shape as Theta, see below). They represent respectively the “shape” and “rate” parameters of Gamma distribution over Theta. Similarly, L_s, L_r are the shape and rate parameters of the Gamma over Beta.
- Theta (csc_matrix, shape (n_users,k)) – The expected user latent factors.
- Beta (csc_matrix, shape (n_items,k)) – The expected item latent factors.
References
- Gopalan, Prem, Jake M. Hofman, and David M. Blei. Scalable Recommendation with Hierarchical Poisson Factorization. In UAI, pp. 326-335. 2015.
-
fit
(X)[source]¶ Fit the model to observations.
Parameters: X (scipy sparse matrix, required) – the user-item preference matrix (traning data), in a scipy sparse format (e.g., csc_matrix).
-
rank
(user_index, known_items=None)[source]¶ Rank all test items for a given user.
Parameters: - user_index (int, required) – The index of the user for whom to perform item raking.
- known_items (1d array, optional, default: None) – A list of item indices already known by the user
Returns: Array of item indices sorted (in decreasing order) relative to some user preference scores.
Return type: Numpy 1d array
-
score
(user_index, item_indexes=None)[source]¶ Predict the scores/ratings of a user for a list of items.
Parameters: - user_index (int, required) – The index of the user for whom to perform score predictions.
- item_indexes (1d array, optional, default: None) – A list of item indexes for which to predict the rating score. When “None”, score prediction is performed for all test items of the given user.
Returns: Array containing the predicted values for the items of interest
Return type: Numpy 1d array
Bayesian Personalized Ranking (BPR)¶
@author: Guo Jingyao
-
class
cornac.models.bpr.recom_bpr.
BPR
(k=5, max_iter=100, learning_rate=0.001, lamda=0.001, batch_size=100, name='bpr', trainable=True, init_params={'U': None, 'V': None})[source]¶ Bayesian Personalized Ranking.
Parameters: - k (int, optional, default: 5) – The dimension of the latent factors.
- max_iter (int, optional, default: 100) – Maximum number of iterations or the number of epochs for SGD.
- learning_rate (float, optional, default: 0.001) – The learning rate for SGD.
- lamda (float, optional, default: 0.001) – The regularization parameter.
- batch_size (int, optional, default: 100) – The batch size for SGD.
- name (string, optional, default: 'BRP') – The name of the recommender model.
- trainable (boolean, optional, default: True) – When False, the model is not trained and Cornac assumes that the model already pre-trained (U and V are not None).
- init_params (dictionary, optional, default: {'U':None,'V':None}) – List of initial parameters, e.g., init_params = {‘U’:U, ‘V’:V}. U: a csc_matrix of shape (n_users,k), containing the user latent factors. V: a csc_matrix of shape (n_items,k), containing the item latent factors.
References
- Rendle, Steffen, Christoph Freudenthaler, Zeno Gantner, and Lars Schmidt-Thieme. BPR: Bayesian personalized ranking from implicit feedback. In UAI, pp. 452-461. 2009.
-
fit
(X)[source]¶ Fit the model to observations.
Parameters: X (scipy sparse matrix, required) – the user-item preference matrix (traning data), in a scipy sparse format (e.g., csc_matrix).
-
rank
(user_index, known_items=None)[source]¶ Rank all test items for a given user.
Parameters: - user_index (int, required) – The index of the user for whom to perform item raking.
- known_items (1d array, optional, default: None) – A list of item indices already known by the user
Returns: Array of item indices sorted (in decreasing order) relative to some user preference scores.
Return type: Numpy 1d array
-
score
(user_index, item_indexes=None)[source]¶ Predict the scores/ratings of a user for a list of items.
Parameters: - user_index (int, required) – The index of the user for whom to perform score predictions.
- item_indexes (1d array, optional, default: None) – A list of item indexes for which to predict the rating score. When “None”, score prediction is performed for all test items of the given user.
Returns: Array containing the predicted values for the items of interest
Return type: Numpy 1d array
Probabilitic Matrix Factorization (PMF)¶
@author: Aghiles Salah
-
class
cornac.models.pmf.recom_pmf.
PMF
(k=5, max_iter=100, learning_rate=0.001, gamma=0.9, lamda=0.001, name='pmf', variant='non_linear', trainable=True, rating_range=[None, None], init_params={'U': None, 'V': None})[source]¶ Probabilistic Matrix Factorization.
Parameters: - k (int, optional, default: 5) – The dimension of the latent factors.
- max_iter (int, optional, default: 100) – Maximum number of iterations or the number of epochs for SGD.
- learning_rate (float, optional, default: 0.001) – The learning rate for SGD_RMSProp.
- gamma (float, optional, default: 0.9) – The weight for previous/current gradient in RMSProp.
- lamda (float, optional, default: 0.001) – The regularization parameter.
- name (string, optional, default: 'PMF') – The name of the recommender model.
- variant ({"linear","non_linear"}, optional, default: 'non_linear') – Pmf variant. If ‘non_linear’, the Gaussian mean is the output of a Sigmoid function. If ‘linear’ the Gaussian mean is the output of the identity function.
- trainable (boolean, optional, default: True) – When False, the model is not trained and Cornac assumes that the model already pre-trained (U and V are not None).
- rating_range (1d array, optional, default: [None,None]) – The minimum and maximum rating values, e.g., [1,5].
- init_params (dictionary, optional, default: {'U':None,'V':None}) – List of initial parameters, e.g., init_params = {‘U’:U, ‘V’:V}. U: a csc_matrix of shape (n_users,k), containing the user latent factors. V: a csc_matrix of shape (n_items,k), containing the item latent factors.
References
- Mnih, Andriy, and Ruslan R. Salakhutdinov. Probabilistic matrix factorization. In NIPS, pp. 1257-1264. 2008.
-
fit
(X)[source]¶ Fit the model to observations.
Parameters: X (scipy sparse matrix, required) – the user-item preference matrix (traning data), in a scipy sparse format (e.g., csc_matrix).
-
rank
(user_index, known_items=None)[source]¶ Rank all test items for a given user.
Parameters: - user_index (int, required) – The index of the user for whom to perform item raking.
- known_items (1d array, optional, default: None) – A list of item indices already known by the user
Returns: Array of item indices sorted (in decreasing order) relative to some user preference scores.
Return type: Numpy 1d array
-
score
(user_index, item_indexes=None)[source]¶ Predict the scores/ratings of a user for a list of items.
Parameters: - user_index (int, required) – The index of the user for whom to perform score predictions.
- item_indexes (1d array, optional, default: None) – A list of item indexes for which to predict the rating score. When “None”, score prediction is performed for all test items of the given user.
Returns: Array containing the predicted values for the items of interest
Return type: Numpy 1d array