Class Clusterer<T extends Clusterable>
- java.lang.Object
-
- org.apache.commons.math3.ml.clustering.Clusterer<T>
-
- Type Parameters:
T
- the type of points that can be clustered
- Direct Known Subclasses:
DBSCANClusterer
,FuzzyKMeansClusterer
,KMeansPlusPlusClusterer
,MultiKMeansPlusPlusClusterer
public abstract class Clusterer<T extends Clusterable> extends java.lang.Object
Base class for clustering algorithms.- Since:
- 3.2
-
-
Field Summary
Fields Modifier and Type Field Description private DistanceMeasure
measure
The distance measure to use.
-
Constructor Summary
Constructors Modifier Constructor Description protected
Clusterer(DistanceMeasure measure)
Build a new clusterer with the givenDistanceMeasure
.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract java.util.List<? extends Cluster<T>>
cluster(java.util.Collection<T> points)
Perform a cluster analysis on the given set ofClusterable
instances.protected double
distance(Clusterable p1, Clusterable p2)
Calculates the distance between twoClusterable
instances with the configuredDistanceMeasure
.DistanceMeasure
getDistanceMeasure()
Returns theDistanceMeasure
instance used by this clusterer.
-
-
-
Field Detail
-
measure
private DistanceMeasure measure
The distance measure to use.
-
-
Constructor Detail
-
Clusterer
protected Clusterer(DistanceMeasure measure)
Build a new clusterer with the givenDistanceMeasure
.- Parameters:
measure
- the distance measure to use
-
-
Method Detail
-
cluster
public abstract java.util.List<? extends Cluster<T>> cluster(java.util.Collection<T> points) throws MathIllegalArgumentException, ConvergenceException
Perform a cluster analysis on the given set ofClusterable
instances.- Parameters:
points
- the set ofClusterable
instances- Returns:
- a
List
of clusters - Throws:
MathIllegalArgumentException
- if points are null or the number of data points is not compatible with this clustererConvergenceException
- if the algorithm has not yet converged after the maximum number of iterations has been exceeded
-
getDistanceMeasure
public DistanceMeasure getDistanceMeasure()
Returns theDistanceMeasure
instance used by this clusterer.- Returns:
- the distance measure
-
distance
protected double distance(Clusterable p1, Clusterable p2)
Calculates the distance between twoClusterable
instances with the configuredDistanceMeasure
.- Parameters:
p1
- the first clusterablep2
- the second clusterable- Returns:
- the distance between the two clusterables
-
-