km = KModes(n_clusters=4, init='Huang', n_init=5, verbose=1)
clusters = km.fit_predict(Trade_DataFrame)
print(km.cluster_centroids_)
Trade_DataFrame['clusters']=clusters ## how do i use this to see what features belong to each
我得到了这个结果,但不确定是什么意思,为什么4是最好的?因为成本最低?
Run 4, iteration: 1/100, moves: 1692, cost: 118602.0
Run 4, iteration: 2/100, moves: 659, cost: 117828.0
Run 4, iteration: 3/100, moves: 242, cost: 117828.0
Init: initializing centroids
Init: initializing clusters
Starting iterations...
Run 5, iteration: 1/100, moves: 1486, cost: 121893.0
Run 5, iteration: 2/100, moves: 66, cost: 121893.0
Best run was number 4