Hy all,
我有一个panda DataFrame,我想从中聚集所有行并获取每个集群质心的行索引。我正在使用sklearn,这就是我所拥有的:
import pandas as pd
import numpy as np
from sklearn.cluster import KMeans
X = pd.DataFrame(np.random.rand(10,5))
kmeans = KMeans(n_clusters=3)
Y = pd.DataFrame(kmeans.fit_predict(X.as_matrix()),columns=['cluster ID'] )
Z =pd.DataFrame(kmeans.cluster_centers_[Y['cluster ID']])
result = pd.concat([X , Y, Z], axis=1)
pd.DataFrame(result)
有没有办法让最近一行的索引到质心
THX
答案 0 :(得分:0)
THX。这段代码工作:
RewriteRule "^/products/latest" "new-products" [R]