Skip to content

A mistake in modes' initialisation leading to incorrect incremental k-modes implementation #1

@asapegin

Description

@asapegin

clusters = [Cluster(centroid.record) for centroid in rdd.takeSample(False, n_partitions * n_clusters, seed=None)]

On the line 253, modes are initialised by randomly selecting records from the whole rdd (and not from the corresponding partition).

As a result, on line 96, the random modes initialised from the whole dataset are used instead of modes for the particular partition.

In most cases, this results in undefined behaviour of the algorithm, i.e. in attempt to use records from one partition with the mode from another partition. In turn, this leads to empty clusters (which should never happen in the incremental k-means/k-modes, please see https://stackoverflow.com/questions/43445863/k-meansupdaing-centroids-successively-after-each-addition for details). In the code, it is solved with the function "check_for_empty_cluster(clusters, rdd)" which replaces the mode of emty cluster with a random one in the middle of k-modes execution.

All in all, this leads to the wrong results of the clustering.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions