Class GeneralisedKMeans<T>
java.lang.Object
org.ojalgo.data.cluster.GeneralisedKMeans<T>
- All Implemented Interfaces:
ClusteringAlgorithm<T>
Contains the outline of the k-means algorithm, but designed for customisation.
- Works with any type of data
- Allows for custom distance calculations
- Allows for custom centroid initialisation and updating
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final NumberContextprivate final Function<Collection<T>, List<T>> private final Function<Collection<T>, T> private final ToDoubleBiFunction<T, T> -
Constructor Summary
ConstructorsConstructorDescriptionGeneralisedKMeans(Function<Collection<T>, List<T>> centroidInitialiser, Function<Collection<T>, T> centroidUpdater, ToDoubleBiFunction<T, T> distanceCalculator) You have to configure how distances are measured and how centroids are derived. -
Method Summary
-
Field Details
-
ACCURACY
-
myCentroidUpdater
-
myDistanceCalculator
-
myCentroidInitialiser
-
-
Constructor Details
-
GeneralisedKMeans
public GeneralisedKMeans(Function<Collection<T>, List<T>> centroidInitialiser, Function<Collection<T>, T> centroidUpdater, ToDoubleBiFunction<T, T> distanceCalculator) You have to configure how distances are measured and how centroids are derived.- Parameters:
centroidInitialiser- The initialisation function should return a list of k centroids. This function determines 'K'.centroidUpdater- The update function should return a new centroid based on a collection of points (the set of items in a cluster).distanceCalculator- A function that calculates the distance between two points.
-
-
Method Details
-
cluster
Description copied from interface:ClusteringAlgorithmPartitions the given items into clusters.- Specified by:
clusterin interfaceClusteringAlgorithm<T>- Parameters:
input- The items to cluster; must not benull. May be empty.- Returns:
- A list of clusters; each element of the list is a
Set<T>representing one cluster and containing its members. Sets are non-empty and pairwise disjoint; ordering is unspecified.
-