Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- from sklearn.cluster import KMeans
- data = pd.read_csv('/datasets/segments.csv')
- model = KMeans(n_clusters=3, random_state=12345)
- model.fit(data)
- centroids = pd.DataFrame(model.cluster_centers_, columns=data.columns)
- print("Типичные пользователи сегментов для 3-х кластеров:")
- print(centroids.round())
- model = KMeans(n_clusters=4, random_state=12345)
- model.fit(data)
- centroids = pd.DataFrame(model.cluster_centers_, columns=data.columns)
- print("Типичные пользователи сегментов для 4-х кластеров:")
- print(centroids.round())
Add Comment
Please, Sign In to add comment