lenskit.knn.slim.SLIMScorer =========================== .. py:class:: lenskit.knn.slim.SLIMScorer(config = None, **kwargs) Bases: :py:obj:`lenskit.pipeline.components.Component`, :py:obj:`lenskit.training.Trainable` Item scorer using Sparse LInear Methods (SLIM). SLIM was described for recommendation by :cite:t`ningSLIMSparseLinear2011`. This scorer supports both SLIM and fsSLIM variants (by setting :attr:`SLIMConfig.max_nbrs`). SLIM operates by learning an elastic-net regression for each item, predicting whether the user will interact with that item based on the other items they have interacted with. This implementation closely follows the paper with some reference to `libslim`_ for computational details. It uses coodrinate descent with soft thresholding :cite:p:`friedmanRegularizationPathsGeneralized2010` to estimate the SLIM weight matrix. .. note:: The coordinate descent method of :cite:t:`friedmanRegularizationPathsGeneralized2010` operates on standardized predictor variables, with a hint that standardization can be inlined to the optimization logic for sparse problems. However, they do not provide details for how to do that inlining, and the original SLIM implementation from the Karypis lab does not appear to center the predictors. Therefore, this implementation also does not center them. .. _libslim: https://github.com/KarypisLab/SLIM/tree/master/src/libslim .. py:attribute:: config :type: SLIMConfig The component configuration object. Component classes that support configuration **must** redefine this attribute with their specific configuration class type, which can be a Python dataclass or a Pydantic model class. .. py:attribute:: weights :type: scipy.sparse.csr_array .. py:attribute:: items :type: lenskit.data.Vocabulary .. py:method:: is_trained() Query if this component has already been trained. .. py:method:: train(data, options) Train the model to learn its parameters from a training dataset. :param data: The training dataset. :param options: The training options. .. py:method:: __call__(query, items) Run the pipeline's operation and produce a result. This is the key method for components to implement.