# Simple K-Medoids Partitioning Algorithm for Mixed Variable Data
## 2 Related Works and the Proposed Method
### Proposed Distance Method  
As a distance-based algorithm, the SKM algorithm input requires a distance function. Compared to distance measures in either numerical or categorical variables, there are limited alternatives for mixed variable distance. Although the most common distance measure for mixed variable data is the Gower distance [9], a generalized distance function (GDF) to increase the variation of the mixed variable choices is developed. The GDF consists of combinations of weights and distances. It sets particular weights in a linear combination of numerical, binary, and categorical distances. The distance between two objects in the GDF form can be computed by:  
\[d_{ij} = \left(\alpha\ \sum_{r=1}^{p_{n}}\delta_{n}(x_{ir},x_{ir})+\beta\ \sum_{t=1}^{p_{k}}\delta_{b}(x_{it},x_{jt})+\ \gamma\ \sum_{s=1}^{p_{c}  
knowledge or intuition, the constants can be transformed into a vector. This transformation, however, results in a subspace clustering domain [10], which is out of the scope of this article.  
By using the GDF, we can reformulate the Gower distance, which is a special case of the GDF. The Gower similarity [9] between object \(i\) and object \(j\) is normally calculated as:  
\[s_{ij} = \frac{\sum_{l=1}^{p}\omega_{ijl}s_{ijl}}{\sum_{l=1}^{p}\omega_{ ijl}}, \tag{2}\]  
\[s_{ijl} = 1-\frac{|x_{il}-x_{jl}|}{R_{l}},\,\text{or}\] \[s_{ijl} \in \{0,1\},\]  
where \(\omega_{ijl}\) is the \(j^{\text{th}}\) weight of object \(i\) in the variable \(l\), \(x_{il}\) is the value of the object \(i\) on the \(l^{\text{th}}\) (numerical) variable, \(R_{l}\) is the range of the \(l^{\text{th}}\) (numerical) variable, and \(s_{ijl}=1\) if the objects \(i\) and \(j\) are similar in the \(l^{\text{th}}\) (binary or categorical) variable and zero otherwise. The Gower distance is then obtained by subtracting one from Equation (2), i.e., \(d_{ij}=1-s_{ij}\). \(\omega_{ijl}\) in the Gower distance regulates the contribution of each variable. \(\omega_{ijl}\) is equal to zero if there is a missing value [22]. When some specific variables are more relevant than others to cluster the objects, \(\omega_{ijl}\) is unequal [10]. This occurs in the domain of subspace clustering. For a conventional clustering method, on the other hand, equal variable weights (\(\omega_{ijl}\)) for all of the variables are applicable. Thus, the Gower distance for a non-missing value dataset and all variables being equally contributed can be formulated in a GDF form into:  
\[d_{ij} = \frac{1}{p_{n}+p_{b}+p_{c}}\left(\sum_{r=1}^{p_{n}}\frac{1}{R_{r}} \left|x_{ir}-x_{jr}\right|+\,p_{b}\sum_{t=1}^{p_{b}}\delta_{b}(x_{it},x_{jt})+ p_{c}\sum_{s=1}^{p_{c}}\delta_{c}(x_{is},x_{js})\right), \tag{3}\]  
where \(R_{r}\) is the range of variable \(r\), \(\delta_{b}(x_{it},x_{jt})=\delta_{c}(x_{is},x_{js})=0\) if object \(i\) and object \(j\) are similar and one otherwise, i.e., simple matching distance. With equally-contributing variables and without any missing value, Equations (2) and (3) are equal (see Appendix A). Equation (3) implies that the distance for the numerical variable is the Manhattan range weighted, while the distance for the binary and categorical variables is the simple matching. The other available distances for mixed variable data, which are less popular than the Gower distance, can be transformed into a GDF form in a similar way. They are the Wishart [23], Podani [22], Huang [5], and Harikumar-PV [7] distances. The Wishart and Podani distances have similar properties to the Gower such that the same assumption applies. The Huang and Harikumar-PV distances, on the other hand, do not admit a missing value and have equally-contributing variables by definition. Table 1 shows the GDF formulation of these distances with respect to their distance combinations and weights. Then, other combinations of distances and weights are possible.