In this section, we will review the concept of K-means with a practical sample, from the very basic concepts.
First, we will import the libraries we need. In order to improve the understanding of the algorithms, we will use the numpy library. Then we will use the well-known matplotlib library for the graphical representation of the algorithms:
import numpy as npimport matplotlibimport matplotlib.pyplot as plt%matplotlib inline
These will be a number of 2D elements, and will then generate the candidate centers, which will be of four 2D elements.
In order to generate a dataset, normally a random number generator is used, but in this case we want to set the samples to predetermined numbers, for convenience, and also ...