EuclideanDistanceSimilarity ClassNReco.Recommender Class Library

An implementation of a "similarity" based on the Euclidean "distance" between two users X and Y. Thinking of items as dimensions and preferences as points along those dimensions, a distance is computed using all items (dimensions) where both users have expressed a preference for that item. This is simply the square root of the sum of the squares of differences in position (preference) along each dimension.

The similarity could be computed as 1 / (1 + distance), so the resulting values are in the range (0,1]. This would weight against pairs that overlap in more dimensions, which should indicate more similarity, since more dimensions offer more opportunities to be farther apart. Actually, it is computed as sqrt(n) / (1 + distance), where n is the number of dimensions, in order to help correct for this. sqrt(n) is chosen since randomly-chosen points have a distance that grows as sqrt(n).

Note that this could cause a similarity to exceed 1; such values are capped at 1.

Note that the distance isn't normalized in any way; it's not valid to compare similarities computed from different domains (different rating scales, for example). Within one domain, normalizing doesn't matter much as it doesn't change ordering.

Inheritance Hierarchy

System Object
  NReco.CF.Taste.Impl.Similarity AbstractItemSimilarity
    NReco.CF.Taste.Impl.Similarity AbstractSimilarity
      NReco.CF.Taste.Impl.Similarity EuclideanDistanceSimilarity

Namespace: NReco.CF.Taste.Impl.Similarity
Assembly: NReco.Recommender (in NReco.Recommender.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax

public sealed class EuclideanDistanceSimilarity : AbstractSimilarity

The EuclideanDistanceSimilarity type exposes the following members.

Constructors

  NameDescription
Public methodEuclideanDistanceSimilarity(IDataModel)
Initializes a new instance of the EuclideanDistanceSimilarity class
Public methodEuclideanDistanceSimilarity(IDataModel, Weighting)
Initializes a new instance of the EuclideanDistanceSimilarity class
Top
Methods

  NameDescription
Public methodAllSimilarItemIDs (Inherited from AbstractItemSimilarity.)
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodItemSimilarities (Inherited from AbstractSimilarity.)
Public methodItemSimilarity (Inherited from AbstractSimilarity.)
Public methodRefresh (Inherited from AbstractSimilarity.)
Public methodSetPreferenceInferrer (Inherited from AbstractSimilarity.)
Public methodToString (Inherited from AbstractSimilarity.)
Public methodUserSimilarity (Inherited from AbstractSimilarity.)
Top
See Also