Class SquaredErrors
- java.lang.Object
-
- elki.evaluation.clustering.internal.SquaredErrors
-
- All Implemented Interfaces:
Evaluator
,ResultProcessor
public class SquaredErrors extends java.lang.Object implements Evaluator
Evaluate a clustering by reporting the squared errors (SSE, SSQ), as used by k-means. This should be used withSquaredEuclideanDistance
only (when used with other distances, it will manually square the values; but beware that the result is less meaningful with other distance functions).For clusterings that provide a cluster prototype object (e.g., k-means), the prototype will be used. For other algorithms, the centroid will be recomputed.
TODO: support non-vector based clusterings, too, if the algorithm provided a prototype object (e.g., PAM).
TODO: when combined with k-means, detect if the distance functions agree (both should be using squared Euclidean), and reuse the SSQ values provided by k-means.
- Since:
- 0.7.0
- Author:
- Erich Schubert
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SquaredErrors.Par
Parameterization class.
-
Field Summary
Fields Modifier and Type Field Description private NumberVectorDistance<?>
distance
Distance function to use.private java.lang.String
key
Key for logging statistics.private static Logging
LOG
Logger for debug output.private NoiseHandling
noiseOption
Handling of Noise clusters
-
Constructor Summary
Constructors Constructor Description SquaredErrors(NumberVectorDistance<?> distance, NoiseHandling noiseOption)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
evaluateClustering(Relation<? extends NumberVector> rel, Clustering<?> c)
Evaluate a single clustering.void
processNewResult(java.lang.Object result)
Process a result.
-
-
-
Field Detail
-
LOG
private static final Logging LOG
Logger for debug output.
-
noiseOption
private NoiseHandling noiseOption
Handling of Noise clusters
-
distance
private NumberVectorDistance<?> distance
Distance function to use.
-
key
private java.lang.String key
Key for logging statistics.
-
-
Constructor Detail
-
SquaredErrors
public SquaredErrors(NumberVectorDistance<?> distance, NoiseHandling noiseOption)
Constructor.- Parameters:
distance
- Distance function to use.noiseOption
- Control noise handling.
-
-
Method Detail
-
evaluateClustering
public double evaluateClustering(Relation<? extends NumberVector> rel, Clustering<?> c)
Evaluate a single clustering.- Parameters:
rel
- Data relationc
- Clustering- Returns:
- ssq
-
processNewResult
public void processNewResult(java.lang.Object result)
Description copied from interface:ResultProcessor
Process a result.- Specified by:
processNewResult
in interfaceResultProcessor
- Parameters:
result
- Newly added result subtree.
-
-