class_docstr: 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). 
      
  verbose: boolean, optional, default: False
      When True, some running logs are displayed.
      
  hierarchical: boolean, optional, default: True
      When False, PF is used instead of HPF.
      
  seed: int, optional, default: None
      Random seed for parameters initialization.
  
  init_params: dict, optional, default: None
      Initial parameters of the model.
      
      Theta: ndarray, shape (n_users, k)
          The expected user latent factors.
      
      Beta: ndarray, shape (n_items, k)
          The expected item latent factors.
  
      G_s: ndarray, shape (n_users, k)
          This represents "shape" parameters of Gamma distribution over Theta.
  
      G_r: ndarray, shape (n_users, k)
          This represents "rate" parameters of Gamma distribution over Theta.
          
      L_s: ndarray, shape (n_items, k)
          This represents "shape" parameters of Gamma distribution over Beta.
      
      L_r: ndarray, shape (n_items, k)
          This represents "rate" parameters of Gamma distribution over Beta.
      
  References
  ----------
  * Gopalan, Prem, Jake M. Hofman, and David M. Blei. Scalable Recommendation with     Hierarchical Poisson Factorization. In UAI, pp. 326-335. 2015.
class_docstr_tok: ["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",")",".","verbose",":","boolean",",","optional",",","default",":","False","When","True",",","some","running","logs","are","displayed",".","hierarchical",":","boolean",",","optional",",","default",":","True","When","False",",","PF","is","used","instead","of","HPF",".","seed",":","int",",","optional",",","default",":","None","Random","seed","for","parameters","initialization",".","init_params",":","dict",",","optional",",","default",":","None","Initial","parameters","of","the","model",".","Theta",":","ndarray",",","shape","(","n_users",",","k",")","The","expected","user","latent","factors",".","Beta",":","ndarray",",","shape","(","n_items",",","k",")","The","expected","item","latent","factors",".","G_s",":","ndarray",",","shape","(","n_users",",","k",")","This","represents","``","shape","''","parameters","of","Gamma","distribution","over","Theta",".","G_r",":","ndarray",",","shape","(","n_users",",","k",")","This","represents","``","rate","''","parameters","of","Gamma","distribution","over","Theta",".","L_s",":","ndarray",",","shape","(","n_items",",","k",")","This","represents","``","shape","''","parameters","of","Gamma","distribution","over","Beta",".","L_r",":","ndarray",",","shape","(","n_items",",","k",")","This","represents","``","rate","''","parameters","of","Gamma","distribution","over","Beta",".","References","--","--","--","--","--","*","Gopalan",",","Prem",",","Jake","M.","Hofman",",","and","David","M.","Blei",".","Scalable","Recommendation","with","Hierarchical","Poisson","Factorization",".","In","UAI",",","pp",".","326-335",".","2015","."]
docstr: Predict the scores/ratings of a user for an item.
  
  Parameters
  ----------
  user_idx: int, required
      The index of the user for whom to perform score prediction.
  
  item_idx: int, optional, default: None
      The index of the item for which to perform score prediction.
      If None, scores for all known items will be returned.
  
  Returns
  -------
  res : A scalar or a Numpy array
      Relative scores that the user gives to the item or to all known items
docstr_tok: ["Predict","the","scores\/ratings","of","a","user","for","an","item",".","Parameters","--","--","--","--","--","user_idx",":","int",",","required","The","index","of","the","user","for","whom","to","perform","score","prediction",".","item_idx",":","int",",","optional",",","default",":","None","The","index","of","the","item","for","which","to","perform","score","prediction",".","If","None",",","scores","for","all","known","items","will","be","returned",".","Returns","--","--","--","-","res",":","A","scalar","or","a","Numpy","array","Relative","scores","that","the","user","gives","to","the","item","or","to","all","known","items"]
code: def score(self, user_idx, item_idx=None):
      """Predict the scores/ratings of a user for an item.
  
      Parameters
      ----------
      user_idx: int, required
          The index of the user for whom to perform score prediction.
  
      item_idx: int, optional, default: None
          The index of the item for which to perform score prediction.
          If None, scores for all known items will be returned.
  
      Returns
      -------
      res : A scalar or a Numpy array
          Relative scores that the user gives to the item or to all known items
  
      """
      if self.is_unknown_user(user_idx):
          raise ScoreException(
              "Can't make score prediction for user %d" % user_idx
          )
  
      if item_idx is not None and self.is_unknown_item(item_idx):
          raise ScoreException(
              "Can't make score prediction for item %d" % item_idx
          )
  
      if item_idx is None:
          known_item_scores = self.Beta.dot(self.Theta[user_idx, :])
          known_item_scores = np.array(
              known_item_scores, dtype="float64"
          ).flatten()
          return known_item_scores
      else:
          user_pred = self.Beta[item_idx, :].dot(
              self.Theta[user_idx, :]
          )
          user_pred = np.array(user_pred, dtype="float64").flatten()[0]
          return user_pred
  
file_path: cornac/cornac/models/hpf/recom_hpf.py
imports: import numpy
  import scipy.sparse
  from cornac.models.hpf import hpf
  from ..recommender import Recommender
  from ..recommender import ANNMixin, MEASURE_DOT
  from ...exception import ScoreException
label_desc: Use image node_id 3 for calling the HPF obj's underlying member method code with example usage: obj.score(user_idx, item_idx) and returns: known_item_scores, user_pred