We have seen K-Means in detail and also it’s Python implementation, In this section, we will be looking at K-Mode implementation in Python.
For K-Mode in python, we will be required to install an additional library. You may download the Kmode library using the steps mentioned in this document.
Remember that to use KModes in Anaconda, you need to install KModes using the conda installer in Anaconda Prompt.
Download the data from below used for Python Lab:
Download the Python code used in the session from below:
Let’s listen to Prof.Dinesh and understand KModes in Python.
In the previous lecture, we prepared the data for K-Mode clustering. To summarise the steps,
- We started with importing libraries including Kmodes library that we will be using to conduct Kmodes in Python.
- Next, we chose the categorical columns and binned age column.
- We encoded the categories to 0 to n using label encoder.
Now let’s perform KModes in that data we have prepared.
Kmodes can be initialised using two main methods namely “Hunag” and “Cao”.
To read in detail about the “Huang” initialisation technique you may read this document. You may also read about “Cao” initialisation technique here.