﻿EuclideanDistanceSimilarity Class
 EuclideanDistanceSimilarity Class NReco.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
EuclideanDistanceSimilarity(IDataModel)
Initializes a new instance of the EuclideanDistanceSimilarity class
EuclideanDistanceSimilarity(IDataModel, Weighting)
Initializes a new instance of the EuclideanDistanceSimilarity class
Top
Methods

NameDescription
AllSimilarItemIDs (Inherited from AbstractItemSimilarity.)
Equals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
GetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
GetType
Gets the Type of the current instance.
(Inherited from Object.)
ItemSimilarities (Inherited from AbstractSimilarity.)
ItemSimilarity (Inherited from AbstractSimilarity.)
Refresh (Inherited from AbstractSimilarity.)
SetPreferenceInferrer (Inherited from AbstractSimilarity.)
ToString (Inherited from AbstractSimilarity.)
UserSimilarity (Inherited from AbstractSimilarity.)
Top