Class SphericalKMeans.Instance

    • Constructor Detail

      • Instance

        public Instance​(Relation<? extends NumberVector> relation,
                        double[][] means)
        Constructor.
        Parameters:
        relation - Data relation
        means - Initial cluster means
    • Method Detail

      • iterate

        public int iterate​(int iteration)
        Description copied from class: AbstractKMeans.Instance
        Main loop function.
        Specified by:
        iterate in class AbstractKMeans.Instance
        Parameters:
        iteration - Iteration number (beginning at 1)
        Returns:
        Number of reassigned points
      • similarity

        protected double similarity​(NumberVector vec1,
                                    double[] vec2)
        Compute the similarity of two objects (and count this operation).
        Parameters:
        vec1 - First vector
        vec2 - Second vector
        Returns:
        Similarity (dot product)
      • similarity

        protected double similarity​(double[] vec1,
                                    double[] vec2)
        Compute the similarity of two objects (and count this operation).
        Parameters:
        vec1 - First vector
        vec2 - Second vector
        Returns:
        Similarity (dot product)
      • distance

        protected double distance​(double[] x,
                                  double[] y)
        Description copied from class: AbstractKMeans.Instance
        Compute the squared distance (and count the distance computations).
        Overrides:
        distance in class AbstractKMeans.Instance
        Parameters:
        x - First object
        y - Second object
        Returns:
        Distance
      • sqrtdistance

        protected double sqrtdistance​(NumberVector x,
                                      double[] y)
        Description copied from class: AbstractKMeans.Instance
        Compute the distance (and count the distance computations). If the distance is squared, also compute the square root.
        Overrides:
        sqrtdistance in class AbstractKMeans.Instance
        Parameters:
        x - First object
        y - Second object
        Returns:
        Distance
      • initialSeparation

        protected void initialSeparation​(double[][] ccsim)
        Initial separation of means. Used by Elkan and Hamerly.
        Parameters:
        ccsim - Output square root of pairwise separation
      • movedSimilarity

        protected void movedSimilarity​(double[][] means,
                                       double[][] newmeans,
                                       double[] sims)
        Similarity to previous locations.

        Used by Hamerly, (Simplified)Elkan.

        Parameters:
        means - Old means
        newmeans - New means
        sims - Similarities moved (output)
      • meansFromSums

        protected void meansFromSums​(double[][] dst,
                                     double[][] sums,
                                     double[][] prev)
        Compute means from cluster sums by adding and normalizing.
        Overrides:
        meansFromSums in class AbstractKMeans.Instance
        Parameters:
        dst - Output means
        sums - Input sums
        prev - Previous means (to handle empty clusters)
      • means

        protected static double[][] means​(java.util.List<? extends DBIDs> clusters,
                                          double[][] means,
                                          Relation<? extends NumberVector> relation)
        Returns the mean vectors of the given clusters in the given database.
        Parameters:
        clusters - the clusters to compute the means
        means - the recent means
        relation - the database containing the vectors
        Returns:
        the mean vectors of the given clusters in the given database