Package org.hipparchus.clustering
Class Clusterer<T extends Clusterable>
- java.lang.Object
-
- org.hipparchus.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.
-
-
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 List<? extends Cluster<T>>
cluster(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.
-
-
-
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) throws MathIllegalArgumentException, MathIllegalStateException
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 clustererMathIllegalStateException
- 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
-
-