Categorical features preprocessing for clustering
Using Gower distance for the clustering. You can find different article about this measure in this and this article.


  Gower Distance is a distance measure that can be used to calculate distance between two entity whose attribute has a mixed of categorical and numerical values. 
  
  Gower distance is computed as the average of partial dissimilarities across individuals. Each partial dissimilarity (and thus Gower distance) ranges in [0 1].
  $$d(i,j) = \frac{1}{p}\sum_{i=1}^{p}d_{ij}^{(f)}$$
  
  Partial dissimilarities ($d_{ij}^{(f)}$) computation depend on the type of variable being evaluated. This implies that a particular standardization will be applied to each feature, and the distance between two individuals is the average of all feature-specific distances.
  
  
  For a numerical feature $f$, partial dissimilarity is the ratio between 1) absolute difference of observations $x_i$ and $x_j$ and 2) maximum range observed from all individuals: $d_{ij}^{(f)} = \frac{|x_i - x_j|}{|(\max_N(x) - \min_N(x))|}$ , $N$ being the number of individuals in the dataset.
  Partial dissimilarity computation for numerical features ($R_f$ = maximal range observed)
  For a qualitative feature $f$ partial dissimilarity equals 1 only if observations $y_i$ and $y_j$ have different value. Zero otherwise.