[Python] Missing cluster in k-means

Discussão em 'Python' iniciado por Stack, Agosto 5, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to analyse a dataset with the k-means algorithm in python with scikit-learn.

    Has anyone ever had the problem of getting less clusters than requested?

    With the input

    from sklearn.cluster import KMeans
    kmeans = KMeans(n_clusters=4)


    my samples are only in cluster 0, 1 and 2. Cluster 3 never appears.

    Doesn't the algorithm recognise that it could take any sample as new cluster(-center) when there is an empty cluster in the end?

    Continue reading...

Compartilhe esta Página