docstr: This method performs iterations of stochastic gradient ascent over the training data.
docstr_tok: ["This","method","performs","iterations","of","stochastic","gradient","ascent","over","the","training","data","."]
code: def fit(self):
      """
      This method performs iterations of stochastic gradient ascent over the training data.
  
      """
  
      for k in range(self.epochs):
          rmse = 0
          count_error = 0
  
          if self.batch:
              self.p = np.dot(self.x, self.w)
  
              for u, user in enumerate(self.users):
                  c, e = self.update_factors(user, u)
                  rmse += e
                  count_error += c
  
              for _ in range(self.n2):
                  for u, user in enumerate(self.users):
                      e = self.p[u] - (np.dot(self.x[u], self.w))
  
                      for l in self.non_zero_x[u]:
                          self.w[l] += self.learn_rate2 * (
                              self.d[u] * np.dot(self.x[u][l], e.T)
                              - (self.w[l] * self.delta2)
                          )
  
              self.p = np.dot(self.x, self.w)
  
          else:
              for u, user in enumerate(self.users):
                  self.p[u] = np.dot(self.x[u], self.w)
                  a = np.array(self.p[u])
                  c, e = self.update_factors(user, u)
                  rmse += e
                  count_error += c
  
                  for l in self.non_zero_x[u]:
                      self.w[l] += (
                          self.d[u] * self.x[u][l] * (self.p[u] - a)
                      )
  
          rmse = np.sqrt(rmse / float(count_error))
  
          if (np.fabs(rmse - self.last_rmse)) <= self.stop_criteria:
              break
          else:
              self.last_rmse = rmse
  
file_path: CaseRecommender/caserec/recommenders/rating_prediction/user_nsvd1.py
imports: import numpy
  from caserec.recommenders.rating_prediction.base_nsvd1 import BaseNSVD1
  from caserec.utils.extra_functions import timed
  from caserec.utils.process_data import ReadFile
label_desc: Use image node_id 3 for calling the UserNSVD1 obj's underlying member method code with example usage: obj.fit() without return types