Top Description Fields Constructors Methods
org.apache.commons.math3.ml.clustering.evaluation

public abstract Class ClusterEvaluator<T extends Clusterable>

extends Object
Class Inheritance
Known Direct Subclasses
org.apache.commons.math3.ml.clustering.evaluation.SumOfClusterVariances
Type Parameters
<T>
type of the clustered points
Imports
java.util.List, org.apache.commons.math3.ml.clustering.CentroidCluster, .Cluster, .Clusterable, .DoublePoint, org.apache.commons.math3.ml.distance.DistanceMeasure, .EuclideanDistance

Base class for cluster evaluation methods.
Since
3.3

Field Summary

Modifier and TypeField and Description
private final DistanceMeasure
measure

The distance measure to use when evaluating the cluster.

Constructor Summary

AccessConstructor and Description
public
ClusterEvaluator()

Creates a new cluster evaluator with an EuclideanDistance as distance measure.

public
ClusterEvaluator(final DistanceMeasure
the distance measure to use
measure
)

Creates a new cluster evaluator with the given distance measure.

Method Summary

Modifier and TypeMethod and Description
protected Clusterable

Returns:

the computed centroid for the cluster, or null if the cluster does not contain any points
centroidOf
(final Cluster<T>
the cluster
cluster
)

Computes the centroid for a cluster.

protected double

Returns:

the distance between the two clusterables
distance
(final Clusterable
the first clusterable
p1
,
final Clusterable
the second clusterable
p2
)

Calculates the distance between two Clusterable instances with the configured DistanceMeasure.

public boolean

Returns:

true if the first score is considered to be better, false otherwise
isBetterScore
(double
the first score
score1
,
double
the second score
score2
)

Returns whether the first evaluation score is considered to be better than the second one by this evaluator.

public abstract double

Returns:

the computed score
score
(List<? extends Cluster<T>>
the clusters to evaluate
clusters
)

Computes the evaluation score for the given list of clusters.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

measureback to summary
private final DistanceMeasure measure

The distance measure to use when evaluating the cluster.

Constructor Detail

ClusterEvaluatorback to summary
public ClusterEvaluator()

Creates a new cluster evaluator with an EuclideanDistance as distance measure.

ClusterEvaluatorback to summary
public ClusterEvaluator(final DistanceMeasure measure)

Creates a new cluster evaluator with the given distance measure.

Parameters
measure:DistanceMeasure

the distance measure to use

Method Detail

centroidOfback to summary
protected Clusterable centroidOf(final Cluster<T> cluster)

Computes the centroid for a cluster.

Parameters
cluster:Cluster<T>

the cluster

Returns:Clusterable

the computed centroid for the cluster, or null if the cluster does not contain any points

distanceback to summary
protected double distance(final Clusterable p1, final Clusterable p2)

Calculates the distance between two Clusterable instances with the configured DistanceMeasure.

Parameters
p1:Clusterable

the first clusterable

p2:Clusterable

the second clusterable

Returns:double

the distance between the two clusterables

isBetterScoreback to summary
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:double

the first score

score2:double

the second score

Returns:boolean

true if the first score is considered to be better, false otherwise

scoreback to summary
public abstract double score(List<? extends Cluster<T>> clusters)

Computes the evaluation score for the given list of clusters.

Parameters
clusters:List<? extends Cluster<T>>

the clusters to evaluate

Returns:double

the computed score