<jupyter_start><jupyter_text>El método de k-means<jupyter_code>import numpy as np
import pandas as pd
data = np.random.random(90).reshape(30,3) #30 filas y 3 columnas
data
#Elijo dos elementos al azar entre los que componen data como centroide de los clusters
c1 = np.random.choice(range(len(data)))
c2 = np.random.choice(range(len(data)))
clust_centers = np.vstack([data[c1],data[c2]])
clust_centers
from scipy.cluster.vq import vq
vq(data, clust_centers)
from scipy.cluster.vq import kmeans
kmeans(data, clust_centers) #Nos da la información de los baricentros<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10472972972972973, 'fraction_numerical': 0.02027027027027027, 'mean_word_length': 6.701298701298701, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '289285', 'license': 'MIT', 'n_tokens_mistral': 234, 'n_tokens_neox': 224, 'n_words': 60, 'path': 'My notebooks/T6 - 3 - K-Means.ipynb', 'repo_name': 'DGV1995/Machine-Learning-Data-Science', 'size': '592'}