<jupyter_start><jupyter_text>MM_12_Clustering_E_Solution Laden der Imports:<jupyter_code>%matplotlib inline
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns; sns.set()  # for plot styling
import numpy as np
from sklearn.datasets.samples_generator import make_blobs


from sklearn.cluster import KMeans<jupyter_output>/home/max/Programme/miniconda3/envs/MM_12/lib/python3.8/site-packages/sklearn/utils/deprecation.py:143: FutureWarning: The sklearn.datasets.samples_generator module is  deprecated in version 0.22 and will be removed in version 0.24. The corresponding classes / functions should instead be imported from sklearn.datasets. Anything that cannot be imported from sklearn.datasets is now part of the private API.
  warnings.warn(message, FutureWarning)<jupyter_text>Laden der Daten:<jupyter_code>data = pd.read_csv("edlich-kmeans-A0.csv")
print(data.head())<jupyter_output>V1        V2        V3
0 -5.340236  4.747246  3.823326
1 -9.587065 -3.434466  9.701839
2 -8.385012 -3.902794  8.514620
3  5.708226  2.658575  5.404482
4 -7.431665 -4.390251  9.003216<jupyter_text>Plotten des Datensatzes<jupyter_code>v1 = data.V1.values
v2 = data.V2.values
v3 = data.V3.values

X, y_true = make_blobs(n_samples=100, centers=4,
                       cluster_std=0.60, random_state=0)

plt.scatter(v1,v2,v3);



from sklearn.cluster import KMeans
kmeans = KMeans(n_clusters=4)
kmeans.fit(X)
y_kmeans = kmeans.predict(X)


plt.scatter(v1,v2,v3, c=y_kmeans, cmap='viridis')

centers = kmeans.cluster_centers_
plt.scatter(centers[:, 0], centers[:, 1], c='black', alpha=0.5);<jupyter_output>/home/max/Programme/miniconda3/envs/MM_12/lib/python3.8/site-packages/matplotlib/collections.py:885: RuntimeWarning: invalid value encountered in sqrt
  scale = np.sqrt(self._sizes) * dpi / 72.0 * self._factor
{'fraction_non_alphanumeric': 0.10928061504667765, 'fraction_numerical': 0.09115870400878638, 'mean_word_length': 4.821086261980831, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '559112', 'license': 'MIT', 'n_tokens_mistral': 791, 'n_tokens_neox': 704, 'n_words': 147, 'path': '.ipynb_checkpoints/MM_12_Clustering_E_Solution-checkpoint.ipynb', 'repo_name': 'MaxMali/MM_12_Clustering_Excercise', 'size': '1821'}