<jupyter_start><jupyter_text>k-means<jupyter_code>from sklearn.cluster import KMeans
import numpy as np
kmeans = KMeans(n_clusters=5)#start with 5 clusters
clusters = kmeans.fit(existing_df) #implement it on data
existing_df$cluster = existing_clustering$clusters
table(existing_df$cluster)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.0875, 'fraction_numerical': 0.00625, 'mean_word_length': 10.464285714285714, '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': '608374', 'license': 'MIT', 'n_tokens_mistral': 119, 'n_tokens_neox': 113, 'n_words': 22, 'path': 'section2/.ipynb_checkpoints/kmeans_real1-checkpoint.ipynb', 'repo_name': 'sanjanapackt/PacktPublishing-Clustering-and-Classification-with-Machine-Learning-in-Python', 'size': '320'}