Class ClusterEvaluator<T extends Clusterable>
java.lang.Object
org.hipparchus.clustering.evaluation.ClusterEvaluator<T>
- Type Parameters:
T
- type of the clustered points
- Direct Known Subclasses:
SumOfClusterVariances
Base class for cluster evaluation methods.
-
Constructor Summary
ConstructorDescriptionCreates a new cluster evaluator with anEuclideanDistance
as distance measure.ClusterEvaluator
(DistanceMeasure measure) Creates a new cluster evaluator with the given distance measure. -
Method Summary
Modifier and TypeMethodDescriptionprotected Clusterable
centroidOf
(Cluster<T> cluster) Computes the centroid for a cluster.protected double
distance
(Clusterable p1, Clusterable p2) Calculates the distance between twoClusterable
instances with the configuredDistanceMeasure
.boolean
isBetterScore
(double score1, double score2) Returns whether the first evaluation score is considered to be better than the second one by this evaluator.abstract double
Computes the evaluation score for the given list of clusters.
-
Constructor Details
-
ClusterEvaluator
public ClusterEvaluator()Creates a new cluster evaluator with anEuclideanDistance
as distance measure. -
ClusterEvaluator
Creates a new cluster evaluator with the given distance measure.- Parameters:
measure
- the distance measure to use
-
-
Method Details
-
score
Computes the evaluation score for the given list of clusters.- Parameters:
clusters
- the clusters to evaluate- Returns:
- the computed score
-
isBetterScore
public boolean isBetterScore(double score1, double score2) Returns whether the first evaluation score is considered to be better than the second one by this evaluator.Specific implementations shall override this method if the returned scores do not follow the same ordering, i.e. smaller score is better.
- Parameters:
score1
- the first scorescore2
- the second score- Returns:
true
if the first score is considered to be better,false
otherwise
-
distance
Calculates the distance between twoClusterable
instances with the configuredDistanceMeasure
.- Parameters:
p1
- the first clusterablep2
- the second clusterable- Returns:
- the distance between the two clusterables
-
centroidOf
Computes the centroid for a cluster.- Parameters:
cluster
- the cluster- Returns:
- the computed centroid for the cluster,
or
null
if the cluster does not contain any points
-