1个回答
请参考这个https://github.com/nicodv/kmodes
安装完之后,用法如下
import numpy as np
from kmodes.kmodes import KModes
# random categorical data
data = np.random.choice(20, (100, 10))
km = KModes(n_clusters=4, init='Huang', n_init=5, verbose=1)
clusters = km.fit_predict(data)
# Print the cluster centroids
print(km.cluster_centroids_)
SofaSofa数据科学社区DS面试题库 DS面经