Using a hierarchical clustering library

We will group together a list of points using a hierarchical clustering approach. We will start by assuming that each point is its own cluster. The two closest clusters merge together and the algorithm repeats until the stopping criteria is met. In this algorithm, we will use a library to run hierarchical clustering until there are a specific number of clusters remaining.

Getting ready

Install the hierarchical clustering package using cabal as follows (documentation is available at http://hackage.haskell.org/package/hierarchical-clustering):

$ cabal install hierarchical-clustering

How to do it…

Insert the following code in a new file, which we call Main.hs:

  1. Import the required library:
    import Data.Clustering.Hierarchical ...

Get Haskell Data Analysis Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.