Package elki.clustering.kmeans.spherical
Class SphericalKMeans.Instance
- java.lang.Object
-
- elki.clustering.kmeans.AbstractKMeans.Instance
-
- elki.clustering.kmeans.spherical.SphericalKMeans.Instance
-
- Direct Known Subclasses:
EuclideanSphericalHamerlyKMeans.Instance
,EuclideanSphericalSimplifiedElkanKMeans.Instance
,SphericalHamerlyKMeans.Instance
,SphericalSimplifiedElkanKMeans.Instance
,SphericalSimplifiedHamerlyKMeans.Instance
,SphericalSingleAssignmentKMeans.Instance
- Enclosing class:
- SphericalKMeans<V extends NumberVector>
public static class SphericalKMeans.Instance extends AbstractKMeans.Instance
Instance for a particular data set.- Author:
- Alexander Voß
-
-
Field Summary
-
Fields inherited from class elki.clustering.kmeans.AbstractKMeans.Instance
assignment, clusters, diststat, isSquared, k, key, means, relation, varsum
-
-
Constructor Summary
Constructors Constructor Description Instance(Relation<? extends NumberVector> relation, double[][] means)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
assignToNearestCluster()
Assign each object to the nearest cluster.protected double
distance(double[] x, double[] y)
Compute the squared distance (and count the distance computations).protected double
distance(NumberVector x, double[] y)
Compute the squared distance (and count the distance computations).protected double
distance(NumberVector x, NumberVector y)
Compute the squared distance (and count the distance computations).protected Logging
getLogger()
Get the class logger.protected void
initialSeparation(double[][] ccsim)
Initial separation of means.int
iterate(int iteration)
Main loop function.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.protected void
meansFromSums(double[][] dst, double[][] sums, double[][] prev)
Compute means from cluster sums by adding and normalizing.protected void
movedSimilarity(double[][] means, double[][] newmeans, double[] sims)
Similarity to previous locations.protected void
recomputeVariance(Relation<? extends NumberVector> relation)
Recompute the cluster variances.protected double
similarity(double[] vec1, double[] vec2)
Compute the similarity of two objects (and count this operation).protected double
similarity(NumberVector vec1, double[] vec2)
Compute the similarity of two objects (and count this operation).protected double
sqrtdistance(NumberVector x, double[] y)
Compute the distance (and count the distance computations).protected double
sqrtdistance(NumberVector x, NumberVector y)
Compute the distance (and count the distance computations).-
Methods inherited from class elki.clustering.kmeans.AbstractKMeans.Instance
buildResult, buildResult, computeSquaredSeparation, copyMeans, initialSeperation, movedDistance, recomputeSeperation, run, sqrtdistance
-
-
-
-
Constructor Detail
-
Instance
public Instance(Relation<? extends NumberVector> relation, double[][] means)
Constructor.- Parameters:
relation
- Data relationmeans
- Initial cluster means
-
-
Method Detail
-
iterate
public int iterate(int iteration)
Description copied from class:AbstractKMeans.Instance
Main loop function.- Specified by:
iterate
in classAbstractKMeans.Instance
- Parameters:
iteration
- Iteration number (beginning at 1)- Returns:
- Number of reassigned points
-
assignToNearestCluster
protected int assignToNearestCluster()
Description copied from class:AbstractKMeans.Instance
Assign each object to the nearest cluster.- Overrides:
assignToNearestCluster
in classAbstractKMeans.Instance
- Returns:
- number of objects reassigned
-
similarity
protected double similarity(NumberVector vec1, double[] vec2)
Compute the similarity of two objects (and count this operation).- Parameters:
vec1
- First vectorvec2
- 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 vectorvec2
- 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 classAbstractKMeans.Instance
- Parameters:
x
- First objecty
- Second object- Returns:
- Distance
-
distance
protected double distance(NumberVector x, double[] y)
Description copied from class:AbstractKMeans.Instance
Compute the squared distance (and count the distance computations).- Overrides:
distance
in classAbstractKMeans.Instance
- Parameters:
x
- First objecty
- Second object- Returns:
- Distance
-
distance
protected double distance(NumberVector x, NumberVector y)
Description copied from class:AbstractKMeans.Instance
Compute the squared distance (and count the distance computations).- Overrides:
distance
in classAbstractKMeans.Instance
- Parameters:
x
- First objecty
- 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 classAbstractKMeans.Instance
- Parameters:
x
- First objecty
- Second object- Returns:
- Distance
-
sqrtdistance
protected double sqrtdistance(NumberVector x, NumberVector 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 classAbstractKMeans.Instance
- Parameters:
x
- First objecty
- 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 meansnewmeans
- New meanssims
- 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 classAbstractKMeans.Instance
- Parameters:
dst
- Output meanssums
- Input sumsprev
- Previous means (to handle empty clusters)
-
recomputeVariance
protected void recomputeVariance(Relation<? extends NumberVector> relation)
Description copied from class:AbstractKMeans.Instance
Recompute the cluster variances.- Overrides:
recomputeVariance
in classAbstractKMeans.Instance
- Parameters:
relation
- Data relation
-
getLogger
protected Logging getLogger()
Description copied from class:AbstractKMeans.Instance
Get the class logger.- Specified by:
getLogger
in classAbstractKMeans.Instance
- Returns:
- Logger
-
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 meansmeans
- the recent meansrelation
- the database containing the vectors- Returns:
- the mean vectors of the given clusters in the given database
-
-