class_docstr: ItemKNN is a basic model that compute item similarity with the interaction matrix.
class_docstr_tok: ["ItemKNN","is","a","basic","model","that","compute","item","similarity","with","the","interaction","matrix","."]
code: def __init__(self, config, dataset):
      super(ItemKNN, self).__init__(config, dataset)
  
      # load parameters info
      self.k = config["k"]
      self.shrink = config["shrink"] if "shrink" in config else 0.0
  
      self.interaction_matrix = dataset.inter_matrix(form="csr").astype(
          np.float32
      )
      shape = self.interaction_matrix.shape
      assert self.n_users == shape[0] and self.n_items == shape[1]
      _, self.w = ComputeSimilarity(
          self.interaction_matrix, topk=self.k, shrink=self.shrink
      ).compute_similarity("item")
      self.pred_mat = self.interaction_matrix.dot(self.w).tolil()
  
      self.fake_loss = torch.nn.Parameter(torch.zeros(1))
      self.other_parameter_name = ["w", "pred_mat"]
  
file_path: RecBole/recbole/model/general_recommender/itemknn.py
imports: import numpy
  import scipy.sparse
  import torch
  from recbole.model.abstract_recommender import GeneralRecommender
  from recbole.utils import InputType, ModelType
label_desc: Use image node_id 1 to create a new ItemKNN object from inherited base classes: GeneralRecommender with example: obj = ItemKNN(config, dataset)