from pyclustering.cluster.xmeans import xmeans
from pyclustering.cluster.center_initializer import kmeans_plusplus_initializer
from pyclustering.utils import draw_clusters
from pyclustering.cluster import cluster_visualizer, cluster_visualizer_multidim
import pandas as pd
import numpy as np
from sklearn.preprocessing import MinMaxScaler


csv_data = pd.read_csv(r"../Files/features_v3.csv", header=None)
metrix = csv_data.values
scaler = MinMaxScaler()
y = metrix[:, 8]
print(y.shape)
X = np.delete(metrix, 8, axis=1)
print(metrix.shape, X.shape)
X_scaled = scaler.fit_transform(X)
# print(X_scaled)
print(np.max(X_scaled))

data_input = X_scaled.tolist()

init_centers = kmeans_plusplus_initializer(data_input, 3).initialize()

instance = xmeans(data=data_input, initial_centers=init_centers)
instance.process()

clusters = instance.get_clusters()
# centers = instance.get_centers()

visualizer = cluster_visualizer_multidim()
visualizer.append_clusters(clusters, data_input)
# visualizer.append_cluster(centers, None, marker="*", markersize=10)

visualizer.show(max_row_size=3)

from pyclustering.cluster.xmeans import xmeans
from pyclustering.cluster.center_initializer import kmeans_plusplus_initializer
from pyclustering.utils import draw_clusters
from pyclustering.cluster import cluster_visualizer, cluster_visualizer_multidim
import pandas as pd
import numpy as np
from sklearn.preprocessing import MinMaxScaler


csv_data = pd.read_csv(r"../Files/features_v3.csv", header=None)
metrix = csv_data.values
scaler = MinMaxScaler()
y = metrix[:, 8]
print(y.shape)
X = np.delete(metrix, 8, axis=1)
print(metrix.shape, X.shape)
X_scaled = scaler.fit_transform(X)
# print(X_scaled)
print(np.max(X_scaled))

data_input = X_scaled.tolist()

init_centers = kmeans_plusplus_initializer(data_input, 3).initialize()

instance = xmeans(data=data_input, initial_centers=init_centers)
instance.process()

clusters = instance.get_clusters()
# centers = instance.get_centers()

visualizer = cluster_visualizer_multidim()
visualizer.append_clusters(clusters, data_input)
# visualizer.append_cluster(centers, None, marker="*", markersize=10)

visualizer.show(max_row_size=3)

# print(X_scaled) # centers = instance.get_centers() # visualizer.append_cluster(centers, None, marker="*", markersize=10)