Agglomerative Clustering Algorithm

  1. Read Data:

    Read the input data points from the standard input (stdin).

  2. Preprocess Data:

    Parse the input data points and store them in a list.

  3. Initialize Clusters:

    Initialize the clusters using the first n data points.

  4. Define Euclidean Distance Function:

    Define a function to calculate the Euclidean distance between data points.

  5. Main Loop:

    Iterate until the number of clusters reaches the desired value (k).

  6. Update Clusters:

    Calculate the pairwise distances between clusters and merge the two closest clusters.

Code