<jupyter_start><jupyter_text>As we can see, there are 4 clusters. K-Means<jupyter_code>kmeans = KMeans(n_clusters=4)
kmeans.fit(df)

#predictions from kmeans
pred = kmeans.predict(df)
df['cluster'] = pred

#plotting results
color=['orange','green','cyan', 'purple']
for k in range(0,4):
    data = df.loc[df["cluster"]==k]
    plt.scatter(data["Weight"],data["Height"],c=color[k])
plt.title('CLustering with K-Means')
plt.show()<jupyter_output><empty_output><jupyter_text>GMMs<jupyter_code># reload the data
df = pd.read_csv('clustering_gmm.csv')

gmm = GaussianMixture(n_components=4)
gmm.fit(df)

#predictions from gmm
pred = gmm.predict(df)
df['cluster'] = pred
df.columns = ['Weight', 'Height', 'cluster']

color=['orange','green','cyan', 'purple']
for k in range(0,4):
    data = df[df["cluster"]==k]
    plt.scatter(data["Weight"],data["Height"],c=color[k])
plt.title('Clustering with Gaussian Mixture Models')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18808777429467086, 'fraction_numerical': 0.0073145245559038665, 'mean_word_length': 7.3304347826086955, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '553171', 'license': 'MIT', 'n_tokens_mistral': 390, 'n_tokens_neox': 372, 'n_words': 67, 'path': 'Outliers_and_Clustering/GMMs_vs_kmeans.ipynb', 'repo_name': 'hanhanwu/Hanhan_Data_Science_Practice', 'size': '957'}