from pyclustering.cluster.xmeans import (
xmeans, kmeans_plusplus_initializer
)
from pyclustering.utils import draw_clusters
initial_centers = kmeans_plusplus_initializer(df, 2).initialize()
instances = xmeans(df, initial_centers, ccore=True)
instances.process()
KeyError: 0
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
<ipython-input-117-8ff3c8958745> in <module>
6
7 instances = xmeans(X_trans_facility, initial_centers, ccore=True)
----> 8 instances.process()
9
10 clusters = instances.get_clusters()
Use list
or np.ndarray
instead of pd.DataFrame
.
X = df.values
initial_centers = kmeans_plusplus_initializer(X, 2).initialize()
instances = xmeans(X, initial_centers, ccore=True)
instances.process()
https://stackoverflow.com/questions/58135808/how-to-fix-an-error-when-trying-to-cluster-2-rows-in-a-csv-file
Python==3.7.4
pyclustering==0.9.3.1
pandas==1.0.2
Recommended Posts