docstr: Method to predict ratings for all known users in the train set.
docstr_tok: ["Method","to","predict","ratings","for","all","known","users","in","the","train","set","."]
code: def predict(self):
      """
      Method to predict ratings for all known users in the train set.
  
      """
  
      for user in self.users:
          if len(self.train_set["feedback"].get(user, [])) != 0:
              if self.test_file is not None:
                  if self.as_similar_first:
                      self.predictions += (
                          self.predict_similar_first_scores(
                              user,
                              self.test_set["items_seen_by_user"].get(
                                  user, []
                              ),
                          )
                      )
                  else:
                      self.predictions += self.predict_scores(
                          user,
                          self.test_set["items_seen_by_user"].get(
                              user, []
                          ),
                      )
              else:
                  # Selects items that user has not interacted with.
                  items_seen_by_user = []
                  u_list = list(
                      np.flatnonzero(
                          self.matrix[self.user_to_user_id[user]] == 0
                      )
                  )
                  for item_id in u_list:
                      items_seen_by_user.append(
                          self.item_id_to_item[item_id]
                      )
  
                  if self.as_similar_first:
                      self.predictions += (
                          self.predict_similar_first_scores(
                              user, items_seen_by_user
                          )
                      )
                  else:
                      self.predictions += self.predict_scores(
                          user, items_seen_by_user
                      )
          else:
              # Implement cold start user
              pass
  
file_path: CaseRecommender/caserec/recommenders/rating_prediction/itemknn.py
imports: from collections import defaultdict
  import numpy
  from caserec.utils.extra_functions import timed
  from caserec.recommenders.rating_prediction.base_knn import BaseKNN
label_desc: Use image node_id 3 for calling the ItemKNN obj's underlying member method code with example usage: obj.predict() without return types