{"width":"100%","description":"import numpy as npimport matplotlib.pyplot as plt # ===== k-means\u672c\u4f53 =====def init_centroid(X, n_data, k): idx = np.random.permutation(n_data)[:k] centroids = X[idx] return centroidsdef compute_distances(X, k, n_data, centroids): distances = np.zeros((n_data, k)) for idx_centroids in range(k): dist =\u2026","version":"1.0","provider_url":"https://hatena.blog","author_url":"https://blog.hatena.ne.jp/HTN20190109/","image_url":null,"html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Fhtn20190109.hatenablog.com%2Fentry%2F2026%2F03%2F31%2F020026\" title=\"k-means - HTN20190109\u306e\u65e5\u8a18\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","type":"rich","author_name":"HTN20190109","height":"190","provider_name":"Hatena Blog","categories":["DL"],"published":"2026-03-31 02:00:26","blog_title":"HTN20190109\u306e\u65e5\u8a18","url":"https://htn20190109.hatenablog.com/entry/2026/03/31/020026","blog_url":"https://htn20190109.hatenablog.com/","title":"k-means"}