Package smile.manifold
Class UMAP
java.lang.Object
smile.manifold.UMAP
- All Implemented Interfaces:
Serializable
Uniform Manifold Approximation and Projection.
UMAP is a dimension reduction technique that can be used for visualization
similarly to t-SNE, but also for general non-linear dimension reduction.
The algorithm is founded on three assumptions about the data:
- The data is uniformly distributed on a Riemannian manifold;
- The Riemannian metric is locally constant (or can be approximated as such);
- The manifold is locally connected.
References
- McInnes, L, Healy, J, UMAP: Uniform Manifold Approximation and Projection for Dimension Reduction, ArXiv e-prints 1802.03426, 2018
- How UMAP Works: https://umap-learn.readthedocs.io/en/latest/how_umap_works.html
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionfinal double[][]
The coordinate matrix in embedding space.final AdjacencyList
The nearest neighbor graph.final int[]
The original sample index. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic UMAP
of
(double[][] data) Runs the UMAP algorithm.static UMAP
of
(double[][] data, int k) Runs the UMAP algorithm.static UMAP
of
(double[][] data, int k, int d, int iterations, double learningRate, double minDist, double spread, int negativeSamples, double repulsionStrength) Runs the UMAP algorithm.static <T> UMAP
Runs the UMAP algorithm.static <T> UMAP
Runs the UMAP algorithm.static <T> UMAP
of
(T[] data, Distance<T> distance, int k, int d, int iterations, double learningRate, double minDist, double spread, int negativeSamples, double repulsionStrength) Runs the UMAP algorithm.
-
Field Details
-
coordinates
public final double[][] coordinatesThe coordinate matrix in embedding space. -
index
public final int[] indexThe original sample index. -
graph
The nearest neighbor graph.
-
-
Constructor Details
-
UMAP
Constructor.- Parameters:
index
- the original sample index.coordinates
- the coordinates.graph
- the nearest neighbor graph.
-
-
Method Details
-
of
Runs the UMAP algorithm.- Parameters:
data
- the input data.- Returns:
- the model.
-
of
Runs the UMAP algorithm.- Type Parameters:
T
- the data type of points.- Parameters:
data
- the input data.distance
- the distance function.- Returns:
- the model.
-
of
Runs the UMAP algorithm.- Parameters:
data
- the input data.k
- k-nearest neighbors. Larger values result in more global views of the manifold, while smaller values result in more local data being preserved. Generally in the range 2 to 100.- Returns:
- the model.
-
of
Runs the UMAP algorithm.- Type Parameters:
T
- the data type of points.- Parameters:
data
- the input data.distance
- the distance function.k
- k-nearest neighbor. Larger values result in more global views of the manifold, while smaller values result in more local data being preserved. Generally in the range 2 to 100.- Returns:
- the model.
-
of
public static UMAP of(double[][] data, int k, int d, int iterations, double learningRate, double minDist, double spread, int negativeSamples, double repulsionStrength) Runs the UMAP algorithm.- Parameters:
data
- the input data.k
- k-nearest neighbors. Larger values result in more global views of the manifold, while smaller values result in more local data being preserved. Generally in the range 2 to 100.d
- The target embedding dimensions. defaults to 2 to provide easy visualization, but can reasonably be set to any integer value in the range 2 to 100.iterations
- The number of iterations to optimize the low-dimensional representation. Larger values result in more accurate embedding. Muse be at least 10. Choose wise value based on the size of the input data, e.g, 200 for large data (10000+ samples), 500 for small.learningRate
- The initial learning rate for the embedding optimization, default 1.minDist
- The desired separation between close points in the embedding space. Smaller values will result in a more clustered/clumped embedding where nearby points on the manifold are drawn closer together, while larger values will result on a more even disperse of points. The value should be set no-greater than and relative to the spread value, which determines the scale at which embedded points will be spread out. default 0.1.spread
- The effective scale of embedded points. In combination with minDist, this determines how clustered/clumped the embedded points are. default 1.0.negativeSamples
- The number of negative samples to select per positive sample in the optimization process. Increasing this value will result in greater repulsive force being applied, greater optimization cost, but slightly more accuracy, default 5.repulsionStrength
- Weighting applied to negative samples in low dimensional embedding optimization. Values higher than one will result in greater weight being given to negative samples, default 1.0.- Returns:
- the model.
-
of
public static <T> UMAP of(T[] data, Distance<T> distance, int k, int d, int iterations, double learningRate, double minDist, double spread, int negativeSamples, double repulsionStrength) Runs the UMAP algorithm.- Type Parameters:
T
- the data type of points.- Parameters:
data
- the input data.distance
- the distance function.k
- k-nearest neighbor. Larger values result in more global views of the manifold, while smaller values result in more local data being preserved. Generally in the range 2 to 100.d
- The target embedding dimensions. defaults to 2 to provide easy visualization, but can reasonably be set to any integer value in the range 2 to 100.iterations
- The number of iterations to optimize the low-dimensional representation. Larger values result in more accurate embedding. Muse be at least 10. Choose wise value based on the size of the input data, e.g, 200 for large data (1000+ samples), 500 for small.learningRate
- The initial learning rate for the embedding optimization, default 1.minDist
- The desired separation between close points in the embedding space. Smaller values will result in a more clustered/clumped embedding where nearby points on the manifold are drawn closer together, while larger values will result on a more even disperse of points. The value should be set no-greater than and relative to the spread value, which determines the scale at which embedded points will be spread out. default 0.1.spread
- The effective scale of embedded points. In combination with minDist, this determines how clustered/clumped the embedded points are. default 1.0.negativeSamples
- The number of negative samples to select per positive sample in the optimization process. Increasing this value will result in greater repulsive force being applied, greater optimization cost, but slightly more accuracy, default 5.repulsionStrength
- Weighting applied to negative samples in low dimensional embedding optimization. Values higher than one will result in greater weight being given to negative samples, default 1.0.- Returns:
- the model.
-