class_docstr: Embarrassingly Shallow Autoencoders for Sparse Data.
  
  Parameters
  ----------
  name: string, optional, default: 'EASEᴿ'
      The name of the recommender model.
  
  lamb: float, optional, default: 500
      L2-norm regularization-parameter λ ∈ R+.
  
  posB: boolean, optional, default: False
      Remove Negative Weights
  
  trainable: boolean, optional, default: True
      When False, the model is not trained and Cornac assumes that the model is already         trained. 
      
  verbose: boolean, optional, default: False
      When True, some running logs are displayed.
  
  seed: int, optional, default: None
      Random seed for parameters initialization.
  
  References
  ----------
  * Steck, H. (2019, May). "Embarrassingly shallow autoencoders for sparse data."     In The World Wide Web Conference (pp. 3251-3257).
class_docstr_tok: ["Embarrassingly","Shallow","Autoencoders","for","Sparse","Data",".","Parameters","--","--","--","--","--","name",":","string",",","optional",",","default",":","'EASE\u1d3f'","The","name","of","the","recommender","model",".","lamb",":","float",",","optional",",","default",":","500","L2-norm","regularization-parameter","\u03bb","\u2208","R+",".","posB",":","boolean",",","optional",",","default",":","False","Remove","Negative","Weights","trainable",":","boolean",",","optional",",","default",":","True","When","False",",","the","model","is","not","trained","and","Cornac","assumes","that","the","model","is","already","trained",".","verbose",":","boolean",",","optional",",","default",":","False","When","True",",","some","running","logs","are","displayed",".","seed",":","int",",","optional",",","default",":","None","Random","seed","for","parameters","initialization",".","References","--","--","--","--","--","*","Steck",",","H.","(","2019",",","May",")",".","``","Embarrassingly","shallow","autoencoders","for","sparse","data",".","''","In","The","World","Wide","Web","Conference","(","pp",".","3251-3257",")","."]
docstr: Fit the model to observations.
  
  Parameters
  ----------
  train_set: :obj:`cornac.data.Dataset`, required
      User-Item preference data as well as additional modalities.
  
  val_set: :obj:`cornac.data.Dataset`, optional, default: None
      User-Item preference data for model selection purposes (e.g., early stopping).
  
  Returns
  -------
  self : object
docstr_tok: ["Fit","the","model","to","observations",".","Parameters","--","--","--","--","--","train_set",":",":","obj",":","`","cornac.data.Dataset","`",",","required","User-Item","preference","data","as","well","as","additional","modalities",".","val_set",":",":","obj",":","`","cornac.data.Dataset","`",",","optional",",","default",":","None","User-Item","preference","data","for","model","selection","purposes","(","e.g.",",","early","stopping",")",".","Returns","--","--","--","-","self",":","object"]
code: def fit(self, train_set, val_set=None):
      """Fit the model to observations.
  
      Parameters
      ----------
      train_set: :obj:`cornac.data.Dataset`, required
          User-Item preference data as well as additional modalities.
  
      val_set: :obj:`cornac.data.Dataset`, optional, default: None
          User-Item preference data for model selection purposes (e.g., early stopping).
  
      Returns
      -------
      self : object
      """
      Recommender.fit(self, train_set, val_set)
  
      # A rating matrix
      self.U = train_set.matrix
  
      # Gram matrix is X^t X, compute dot product
      G = self.U.T.dot(self.U).toarray()
  
      diag_indices = np.diag_indices(G.shape[0])
  
      G[diag_indices] = G.diagonal() + self.lamb
  
      P = np.linalg.inv(G)
  
      B = P / (-np.diag(P))
  
      B[diag_indices] = 0.0
  
      # if self.posB remove -ve values
      if self.posB:
          B[B < 0] = 0
  
      # save B for predictions
      self.B = B
  
      return self
  
file_path: cornac/cornac/models/ease/recom_ease.py
imports: import numpy
  from ..recommender import Recommender
  from ..recommender import ANNMixin, MEASURE_DOT
  from ...exception import ScoreException
label_desc: Use image node_id 2 for calling the EASE obj's underlying member method code with example usage: obj.fit(train_set, val_set) and returns: self