Class NaiveAgglomerativeHierarchicalClustering2<O>

  • Type Parameters:
    O - Object type
    All Implemented Interfaces:
    Algorithm

    public class NaiveAgglomerativeHierarchicalClustering2<O>
    extends java.lang.Object
    implements Algorithm
    This tutorial will step you through implementing a well known clustering algorithm, agglomerative hierarchical clustering, in multiple steps.

    This is the second step, where we increase the performance of the algorithm by using an improved linear memory layout instead of ragged arrays.

    This is the naive O(n³) algorithm. See SLINK for a much faster algorithm (however, only for single-linkage).

    Since:
    0.6.0
    Author:
    Erich Schubert
    • Field Detail

      • LOG

        private static final Logging LOG
        Class logger
      • distance

        Distance<? super O> distance
        Distance function used.
      • numclusters

        int numclusters
        Threshold, how many clusters to extract.
    • Constructor Detail

      • NaiveAgglomerativeHierarchicalClustering2

        public NaiveAgglomerativeHierarchicalClustering2​(Distance<? super O> distance,
                                                         int numclusters)
        Constructor.
        Parameters:
        distance - Distance function to use
        numclusters - Number of clusters
    • Method Detail

      • getInputTypeRestriction

        public TypeInformation[] getInputTypeRestriction()
        Description copied from interface: Algorithm
        Get the input type restriction used for negotiating the data query.
        Specified by:
        getInputTypeRestriction in interface Algorithm
        Returns:
        Type restriction
      • run

        public Clustering<Model> run​(Relation<O> relation)
        Perform HAC
        Parameters:
        relation - Data relation
        Returns:
        Clustering
      • triangleSize

        protected static int triangleSize​(int x)
        Compute the size of a complete x by x triangle (minus diagonal)
        Parameters:
        x - Offset
        Returns:
        Size of complete triangle