# How to choose a fair gamma value when performing k-prototypes clustering?

In the k-prototypes clustering algorithm, the distance function consists of two dissimilarity components - one for the numerical elements of the observations, and one for their categorical elements. In pseudo-mathematical terms, we have:

$$d(x, y) = d_1(x_{num}, y_{num}) + \gamma d_2(x_{cat}, y_{cat})$$

where $$\gamma > 0$$ is a weight that allows to favor more or less one of the two data types when building centroids. (Setting $$\gamma$$=0 boils down to performing clustering on numerical variables only, whereas the greater the weight, the greater the impact of categorical variables on the final result.)

In his introduction to k-modes and k-prototypes from 1998, Huang says the following: "Average standard deviation of numeric attributes may be used as a guidance in specifying $$\gamma$$. [...] However, it is too early to consider this as a general rule."

Have some clear mathematical results been found since then? How can I pick a $$\gamma$$ value so that my clustering procedure doesn't favor one data type over the other?

As you already mentioned, and according to the kmodes library, the standard deviation of numeric variables is calculated using the mean:

if gamma is None:
gamma = 0.5 * np.mean(Xnum.std(axis=0))


This is in accordance with Huang [1997]

See this.

Reference:

Huang, Z.X. (1997) Clustering Large Data Sets with Mixed Numeric and Categorical Values. Proceedings of the First Pacific Asia Knowledge Discovery and Data Mining Conference, Singapore, World Scientific, 21-34.

• On second thought, when I use k-prototypes, I usually end up using standardization, which would generate a gamma = 1, considering the mean of the stardart deviations of the numeric data. One approach I have used is to calculate gamma as the ratio between the total numeric dissimilarity and the total categorical dissimilarity Aug 24, 2023 at 16:30