code: def __init__(self, config, dataset):
      super().__init__(config, dataset)
  
      # need at least one param
      self.dummy_param = torch.nn.Parameter(torch.zeros(1))
  
      X = dataset.inter_matrix(form="csr").astype(np.float32)
  
      num_users, num_items = X.shape
  
      lambda1 = config["lambda1"]
      lambda2 = config["lambda2"]
      alpha = config["alpha"]
      rho = config["rho"]
      k = config["k"]
      positive_only = config["positive_only"]
      self.center_columns = config["center_columns"]
      self.item_means = X.mean(axis=0).getA1()
  
      if self.center_columns:
          zero_mean_X = X.toarray() - self.item_means
          G = zero_mean_X.T @ zero_mean_X
          # large memory cost because we need to make X dense to subtract mean, delete asap
          del zero_mean_X
      else:
          G = (X.T @ X).toarray()
  
      diag = lambda2 * np.diag(
          np.power(self.item_means, alpha)
      ) + rho * np.identity(num_items)
  
      P = np.linalg.inv(G + diag).astype(np.float32)
      B_aux = (P @ G).astype(np.float32)
      # initialize
      Gamma = np.zeros_like(G, dtype=np.float32)
      C = np.zeros_like(G, dtype=np.float32)
  
      del diag, G
      # fixed number of iterations
      for _ in range(k):
          B_tilde = B_aux + P @ (rho * C - Gamma)
          gamma = np.diag(B_tilde) / (np.diag(P) + 1e-7)
          B = B_tilde - P * gamma
          C = soft_threshold(B + Gamma / rho, lambda1 / rho)
          if positive_only:
              C = (C > 0) * C
          Gamma += rho * (B - C)
      # torch doesn't support sparse tensor slicing, so will do everything with np/scipy
      self.item_similarity = C
      self.interaction_matrix = X
  
file_path: RecBole/recbole/model/general_recommender/admmslim.py
imports: from recbole.utils.enum_type import ModelType
  import numpy
  import scipy.sparse
  import torch
  from recbole.utils import InputType
  from recbole.model.abstract_recommender import GeneralRecommender
label_desc: Use image node_id 1 to create a new ADMMSLIM object from inherited base classes: GeneralRecommender with example: obj = ADMMSLIM(config, dataset)