human
Can you provide a the Python program you requested given the following:
2. K-means
2.1 Algoritmo completo
Utilizando as funções codificadas anteriormente, complete a classe do algoritmo K-means!
assistant
#Here is the Python program you requested.
class KMeans():
    
    def __init__(self, n_clusters=8, max_iter=300):
        self.n_clusters = n_clusters
        self.max_iter = max_iter
    
    def fit(self,X):
        dataset = np.array(X)
        # Inicializa os centróides
        self.cluster_centers_ = calculate_initial_centers(X, self.n_clusters)
        
        # Computa o cluster de cada amostra
        self.labels_ = [None]
        
            # Calcula a inércia inicial
        old_inertia = [None]
        self.inertia_ = [None]
        
        for index in range(0,self.max_iter):

            nearest_indexes = all_nearest_centroids(dataset, self.cluster_centers_)
            old_inertia = inertia(dataset, self.cluster_centers_, nearest_indexes)
            self.cluster_centers_ = update_centroids(dataset, self.cluster_centers_, nearest_indexes)
            
            # Plota os os cluster ------------------------------------------------
            centroids = self.cluster_centers_
            plt.scatter(dataset[:,0], dataset[:,1], c=nearest_indexes)

            # Plota os centroids
            plt.scatter(centroids[:,0], centroids[:,1], marker='^', c='red', s=100)
            for index, centroid in enumerate(centroids):
                dataframe = dataset[nearest_indexes == index,:]
                for data in dataframe:
                    plt.plot([centroid[0], data[0]], [centroid[1], data[1]], 
                             c='lightgray', alpha=0.3)
            plt.show()
        
        self.inertia_ = old_inertia
            #### CODE HERE ####
    def calculate_initial_centers(dataset, k):
        """
        Inicializa os centróides iniciais de maneira arbitrária 

        Argumentos:
        dataset -- Conjunto de dados - [m,n]
        k -- Número de centróides desejados

        Retornos:
        centroids -- Lista com os centróides calculados - [k,n]
        """
        
        m,n = np.shape(dataset)
        minimum = np.min(dataset)
        maximum = np.max(dataset)

        centroids =...