mirror of
https://github.com/Estom/notes.git
synced 2026-02-03 10:33:35 +08:00
13 lines
272 B
Python
13 lines
272 B
Python
import numpy as np
|
|
from scipy.cluster.vq import kmeans,vq,whiten
|
|
|
|
data = np.vstack((np.random.rand(100,3)+np.array([.5,.5,.5]),np.random.rand(100,3)))
|
|
data = whiten(data)
|
|
|
|
cent,_ = kmeans(data,3)
|
|
|
|
print(cent)
|
|
|
|
# assign each sample to a cluster
|
|
clx,_ = vq(data,centroids)
|