Package org.ojalgo.data.cluster
Class Point
- java.lang.Object
-
- org.ojalgo.data.cluster.Point
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Point.Factory
Primarily used when constructing test cases and similar.
-
Field Summary
Fields Modifier and Type Field Description float[]
coordinates
int
id
-
Constructor Summary
Constructors Constructor Description Point(int id, float[] coordinates)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.util.List<java.util.Set<Point>>
cluster(java.util.Collection<Point> input)
Essentially works like this: Calculate, and store, distances between all the points (to enable statistical analysis, and speed up the following steps) Perform statistical analysis of the distances to determine a suitable distance threshold for greedy clustering Perform greedy clustering to get an initial set of centroids Filter out centroids/clusters corresponding to extremely small clusters (This determines the 'k') Perform k-means clustering to refine the clusters and centroidsint
compareTo(Point ref)
static <T> java.util.List<Point>
convert(java.util.List<T> input, java.util.function.Function<T,float[]> converter)
Converts a list of objects to a list of points using the provided converter to derive the coordinates.double
distance(Point other)
The sum of the squared differences between the coordinates of this and the other point.boolean
equals(java.lang.Object obj)
int
hashCode()
static Point
mean(java.util.Collection<Point> points)
static Point.Factory
newFactory(int dimensions)
static ClusteringAlgorithm<Point>
newGreedyClusterer(double distanceThreshold)
Greedy algorithm.static ClusteringAlgorithm<Point>
newKMeansClusterer(int k)
Standard k-means clusteringstatic Point
of(int id, float... coordinates)
java.lang.String
toString()
-
-
-
Method Detail
-
cluster
public static java.util.List<java.util.Set<Point>> cluster(java.util.Collection<Point> input)
Essentially works like this:- Calculate, and store, distances between all the points (to enable statistical analysis, and speed up the following steps)
- Perform statistical analysis of the distances to determine a suitable distance threshold for greedy clustering
- Perform greedy clustering to get an initial set of centroids
- Filter out centroids/clusters corresponding to extremely small clusters (This determines the 'k')
- Perform k-means clustering to refine the clusters and centroids
-
convert
public static <T> java.util.List<Point> convert(java.util.List<T> input, java.util.function.Function<T,float[]> converter)
Converts a list of objects to a list of points using the provided converter to derive the coordinates. There will be one point for each object in the input list, at matching positions. Further the point id will be the index of the object in the input list.- Type Parameters:
T
- The type of the objects in the input list- Parameters:
input
- The list of objects to convertconverter
- The function to convert the objects to coordinates- Returns:
- A list of points
-
newFactory
public static Point.Factory newFactory(int dimensions)
-
newGreedyClusterer
public static ClusteringAlgorithm<Point> newGreedyClusterer(double distanceThreshold)
Greedy algorithm. The distance measurement is the same as for k-means (distance(Point)
) and the threshold must match that.
-
newKMeansClusterer
public static ClusteringAlgorithm<Point> newKMeansClusterer(int k)
Standard k-means clustering
-
of
public static Point of(int id, float... coordinates)
-
compareTo
public int compareTo(Point ref)
- Specified by:
compareTo
in interfacejava.lang.Comparable<Point>
-
distance
public double distance(Point other)
The sum of the squared differences between the coordinates of this and the other point. (Not the Euclidean distance. This is the squared Euclidean distance.)
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-