import numpy as np
from sklearn.cluster import AgglomerativeClustering
from fdc.visualize import plotCluster

def aglo_clustering(number_of_clusters, affinity, linkage
                    , five_d_embedding, two_d_embedding
                    , visual=False):
    np.random.seed(42)
    ag_cluster = AgglomerativeClustering(
        n_clusters=number_of_clusters
        , affinity=affinity
        , linkage=linkage
        )
    clusters = ag_cluster.fit_predict(five_d_embedding)
    (values, counts) = np.unique(clusters, return_counts=True)
    two_d_embedding['Cluster'] = clusters
    
    if visual:
        plotCluster(two_d_embedding, clusterName="Cluster", xName="UMAP_0", yName="UMAP_1", stroke=3)

    return two_d_embedding.Cluster.to_list(), counts

