Skip to content
Switch branches/tags
Go to file
Cannot retrieve contributors at this time
36 lines (26 sloc) 1.32 KB

k-NN inspired algorithms

These are algorithms that are directly derived from a basic nearest neighbors approach.


For each of these algorithms, the actual number of neighbors that are aggregated to compute an estimation is necessarily less than or equal to k. First, there might just not exist enough neighbors and second, the sets N_i^k(u) and N_u^k(i) only include neighbors for which the similarity measure is positive. It would make no sense to aggregate ratings from users (or items) that are negatively correlated. For a given prediction, the actual number of neighbors can be retrieved in the 'actual_k' field of the details dictionary of the :class:`prediction <surprise.prediction_algorithms.predictions.Prediction>`.

You may want to read the :ref:`User Guide <similarity_measures_configuration>` on how to configure the sim_options parameter.

.. autoclass:: surprise.prediction_algorithms.knns.KNNBasic

.. autoclass:: surprise.prediction_algorithms.knns.KNNWithMeans

.. autoclass:: surprise.prediction_algorithms.knns.KNNWithZScore

.. autoclass:: surprise.prediction_algorithms.knns.KNNBaseline