In statistics, Gower's distance between two mixed-type objects is a similarity measure that can handle different types of data (binary, ordinal, continuous) within the same dataset (unlike Hamming distance or Euclidean distance), by normalizing the differences between each pair of variables and then computing a weighted average of these differences. The distance was defined in 1971 by Gower and it takes values between 0 and 1. This technique is particularly useful in cluster analysis (such as K-nearest neighbors algorithm) or other multivariate statistical techniques.
Definition For two objects i {\displaystyle i} and j {\displaystyle j} having p {\displaystyle p} descriptors, the similarity S {\displaystyle S} is defined as:
S i j = ∑ k = 1 p w i j k s i j k ∑ k = 1 p w i j k , {\displaystyle S_{ij}={\frac {\sum _{k=1}^{p}w_{ijk}s_{ijk}}{\sum _{k=1}^{p}w_{ijk}}},}
where the w i j k {\displaystyle w_{ijk}} are non-negative weights usually set to 1 {\displaystyle 1} and s i j k {\displaystyle s_{ijk}} is the similarity between the two objects regarding their k {\displaystyle k} -th variable. If the variable is binary or ordinal, the values of s i j k {\displaystyle s_{ijk}} are 0 or 1, with 1 denoting equality. If the variable is continuous, s i j k = 1 − | x i − x j | R k {\displaystyle s_{ijk}=1-{\frac {|x_{i}-x_{j}|}{R_{k}}}} with R k {\displaystyle R_{k}} being the range of k {\displaystyle k} -th variable and thus ensuring 0 ≤ s i j k ≤ 1 {\displaystyle 0\leq s_{ijk}\leq 1} . As a result, the overall similarity S i j {\displaystyle S_{ij}} between two objects is the weighted average of the similarities calculated for all their descriptors. In its original exposition, the distance does not treat ordinal variables in a special manner. In the 1990s, first Kaufman and Rousseeuw and later Podani suggested extensions where the ordering of an ordinal feature is used. For example, Podani obtains relative rank differences as s i j k = 1 − | r i − r j | max { r } − min { r } {\displaystyle s_{ijk}=1-{\frac {|r_{i}-r_{j}|}{\max {\{r\}}-\min {\{r\}}}}} with r {\displaystyle r} being the ranks corresponding to the ordered categories of the k {\displaystyle k} -th variable.
References
