I am trying CLARANS clustering with pyclustering module, but for all the data I've tried clarans(data, number_clusters, numlocal, maxneighbor) all the methods returns [] (an empty list) no matter what the parameter values are. I made a random data to test the method, but the answer is the same, the only data that works is the iris data datasets.load_iris() form sklearn module. Am I doing something wrong?
This is the testing data:
import pandas as pd
import numpy as np
import seaborn as sns
from pyclustering.cluster.clarans import clarans
x1 = np.random.normal(10, 5, 100)
x2 = np.random.normal(30, 5, 100)
x = np.concatenate((x1, x2), axis=0)
y1 = np.random.normal(50, 5, 100)
y2 = np.random.normal(60, 5, 100)
y = np.concatenate((y1, y2), axis=0)
Gr = np.array(['G1']*100 + ['G2']*100)
df = pd.DataFrame(x, columns=['X'])
df['Y'] = y
df['Gr'] = Gr
This is when I run the clustering technique (I convert the df to a 2D list):
datalist = np.zeros((200,2))
for i in df.index:
datalist[i][0] = round(float(df['X'][i]), 2)
datalist[i][1] = round(float(df['Y'][i]), 2)
cluster_clarans = clarans(datalist, 2, 6, 4)
cluster_clarans.get_clusters()
And the answer is:
[]