View Source Scholar.Manifold.TSNE (Scholar v0.3.0)

t-SNE (t-Distributed Stochastic Neighbor Embedding) is a nonlinear dimensionality reduction technique.

This is an exact implementation of t-SNE and therefore it has time complexity is $O(N^2)$ for $N$ samples.

Reference

Summary

Functions

Fits tSNE for sample inputs x.

Functions

Fits tSNE for sample inputs x.

Options

  • :num_components (pos_integer/0) - Dimension of the embedded space. The default value is 2.

  • :perplexity (pos_integer/0) - The perplexity is related to the number of nearest neighbors that is used in other manifold learning algorithms. Larger datasets usually require a larger perplexity. Consider selecting a value between 5 and 50. The default value is 30.

  • :learning_rate - The learning rate for t-SNE is usually in the range [10.0, 1000.0]. If the learning rate is too high, the data may look like a 'ball' with any point approximately equidistant from its nearest neighbors. If the learning rate is too low, most points may look compressed in a dense cloud with few outliers. If the cost function gets stuck in a bad local minimum increasing the learning rate may help. The default value is 500.

  • :num_iters (pos_integer/0) - Maximum number of iterations for the optimization. The default value is 500.

  • :key - Determines random number generation for centroid initialization. If the key is not provided, it is set to Nx.Random.key(System.system_time()).

  • :init - Initialization of embedding. Possible options are :random and :pca. The default value is :pca.

  • :metric - Metric used to compute the distances. The default value is :squared_euclidean.

  • :exaggeration - Controls how tight natural clusters in the original space are in the embedded space and how much space will be between them. For larger values, the space between natural clusters will be larger in the embedded space. The default value is 10.0.

  • :learning_loop_unroll (boolean/0) - If true, the learning loop is unrolled. The default value is false.

Return Values

Returns the embedded data y.

Examples

iex> x = Nx.iota({4,5})
iex> key = Nx.Random.key(42)
iex> Scholar.Manifold.TSNE.fit(x, num_components: 2, key: key)
#Nx.Tensor<
  f32[4][2]
  [
    [2197.156005859375, 0.0],
    [1055.1444091796875, 0.0],
    [-1055.1444091796875, 0.0],
    [-2197.156005859375, 0.0]
  ]
>