Class UMAP

java.lang.Object
smile.manifold.UMAP
All Implemented Interfaces:
Serializable

public class UMAP extends Object implements 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.
From these assumptions it is possible to model the manifold with a fuzzy topological structure. The embedding is found by searching for a low dimensional projection of the data that has the closest possible equivalent fuzzy topological structure.

References

  1. McInnes, L, Healy, J, UMAP: Uniform Manifold Approximation and Projection for Dimension Reduction, ArXiv e-prints 1802.03426, 2018
  2. How UMAP Works
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final double[][]
    The coordinate matrix in embedding space.
    The nearest neighbor graph.
    final int[]
    The original sample index.
  • Constructor Summary

    Constructors
    Constructor
    Description
    UMAP(int[] index, double[][] coordinates, AdjacencyList graph)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    static 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
    of(T[] data, Distance<T> distance)
    Runs the UMAP algorithm.
    static <T> UMAP
    of(T[] data, Distance<T> distance, int k)
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • coordinates

      public final double[][] coordinates
      The coordinate matrix in embedding space.
    • index

      public final int[] index
      The original sample index.
    • graph

      public final AdjacencyList graph
      The nearest neighbor graph.
  • Constructor Details

    • UMAP

      public UMAP(int[] index, double[][] coordinates, AdjacencyList graph)
      Constructor.
      Parameters:
      index - the original sample index.
      coordinates - the coordinates.
      graph - the nearest neighbor graph.
  • Method Details

    • of

      public static UMAP of(double[][] data)
      Runs the UMAP algorithm.
      Parameters:
      data - the input data.
      Returns:
      the model.
    • of

      public static <T> UMAP of(T[] data, Distance<T> distance)
      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

      public static UMAP of(double[][] data, int k)
      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

      public static <T> UMAP of(T[] data, Distance<T> distance, int k)
      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.