Class Clusterer<T extends Clusterable>
- java.lang.Object
-
- org.apache.commons.math4.legacy.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 Object
Base class for clustering algorithms.- Since:
- 3.2
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedClusterer(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 List<? extends Cluster<T>>cluster(Collection<T> points)Perform a cluster analysis on the given set ofClusterableinstances.protected doubledistance(Clusterable p1, Clusterable p2)Calculates the distance between twoClusterableinstances with the configuredDistanceMeasure.DistanceMeasuregetDistanceMeasure()Returns theDistanceMeasureinstance used by this clusterer.
-
-
-
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 List<? extends Cluster<T>> cluster(Collection<T> points)
Perform a cluster analysis on the given set ofClusterableinstances.- Parameters:
points- the set ofClusterableinstances- Returns:
- a
Listof clusters - Throws:
IllegalArgumentException- if points are null or the number of data points is not compatible with this clusterer.ConvergenceException- if the algorithm has not yet converged after the maximum number of iterations has been exceeded.
-
getDistanceMeasure
public DistanceMeasure getDistanceMeasure()
Returns theDistanceMeasureinstance used by this clusterer.- Returns:
- the distance measure
-
distance
protected double distance(Clusterable p1, Clusterable p2)
Calculates the distance between twoClusterableinstances with the configuredDistanceMeasure.- Parameters:
p1- the first clusterablep2- the second clusterable- Returns:
- the distance between the two clusterables
-
-