class_docstr: SLIMElastic is a sparse linear method for top-K recommendation, which learns
  a sparse aggregation coefficient matrix by solving an L1-norm and L2-norm
  regularized optimization problem.
class_docstr_tok: ["SLIMElastic","is","a","sparse","linear","method","for","top-K","recommendation",",","which","learns","a","sparse","aggregation","coefficient","matrix","by","solving","an","L1-norm","and","L2-norm","regularized","optimization","problem","."]
code: def __init__(self, config, dataset):
      super().__init__(config, dataset)
  
      # load parameters info
      self.hide_item = config["hide_item"]
      self.alpha = config["alpha"]
      self.l1_ratio = config["l1_ratio"]
      self.positive_only = config["positive_only"]
  
      # need at least one param
      self.dummy_param = torch.nn.Parameter(torch.zeros(1))
  
      X = dataset.inter_matrix(form="csr").astype(np.float32)
      X = X.tolil()
      self.interaction_matrix = X
  
      model = ElasticNet(
          alpha=self.alpha,
          l1_ratio=self.l1_ratio,
          positive=self.positive_only,
          fit_intercept=False,
          copy_X=False,
          precompute=True,
          selection="random",
          max_iter=100,
          tol=1e-4,
      )
      item_coeffs = []
  
      # ignore ConvergenceWarnings
      with warnings.catch_warnings():
          warnings.simplefilter("ignore", category=ConvergenceWarning)
  
          for j in range(X.shape[1]):
              # target column
              r = X[:, j]
  
              if self.hide_item:
                  # set item column to 0
                  X[:, j] = 0
  
              # fit the model
              model.fit(X, r.todense().getA1())
  
              # store the coefficients
              coeffs = model.sparse_coef_
  
              item_coeffs.append(coeffs)
  
              if self.hide_item:
                  # reattach column if removed
                  X[:, j] = r
  
      self.item_similarity = sp.vstack(item_coeffs).T
      self.other_parameter_name = [
          "interaction_matrix",
          "item_similarity",
      ]
  
file_path: RecBole/recbole/model/general_recommender/slimelastic.py
imports: import torch
  import warnings
  import numpy
  import scipy.sparse
  from sklearn.linear_model import ElasticNet
  from sklearn.exceptions import ConvergenceWarning
  from recbole.utils import InputType, ModelType
  from recbole.model.abstract_recommender import GeneralRecommender
label_desc: Use image node_id 1 to create a new SLIMElastic object from inherited base classes: GeneralRecommender with example: obj = SLIMElastic(config, dataset)