View Source Scholar.Manifold.MDS (Scholar v0.3.1)

Multidimensional scaling (MDS) seeks a low-dimensional representation of the data in which the distances respect well the distances in the original high-dimensional space.

Summary

Functions

Fits MDS for sample inputs x. It is simpyfied version of fit/3 function.

Fits MDS for sample inputs x. It is simpyfied version of fit/3 function.

Fits MDS for sample inputs x. It is simpyfied version of fit/3 function.

Functions

Fits MDS for sample inputs x. It is simpyfied version of fit/3 function.

Options

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

  • :metric (boolean/0) - If true, use dissimilarities as metric distances in the embedding space. The default value is true.

  • :normalized_stress (boolean/0) - If true, normalize the stress by the sum of squared dissimilarities. Only valid if metric is false. The default value is false.

  • :eps (float/0) - Tolerance for stopping criterion. The default value is 0.001.

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

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

  • :n_init (pos_integer/0) - Number of times the embedding will be computed with different centroid seeds. The final embedding is the embedding with the lowest stress. The default value is 8.

Return Values

Returns struct with embedded data, stress value, and number of iterations for best run.

Examples

iex> x = Nx.iota({4,5})
iex> key = Nx.Random.key(42)
iex> Scholar.Manifold.MDS.fit(x, key: key)
%Scholar.Manifold.MDS{
  embedding: Nx.tensor(
    [
      [13.072145462036133, -10.424199104309082],
      [5.13038969039917, -2.341259479522705],
      [-5.651908874511719, 1.7662434577941895],
      [-12.550626754760742, 10.999215126037598]
    ]
  ),
  stress: Nx.tensor(
    0.36994707584381104
  ),
  n_iter: Nx.tensor(
    20
  )
}

Fits MDS for sample inputs x. It is simpyfied version of fit/3 function.

Options

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

  • :metric (boolean/0) - If true, use dissimilarities as metric distances in the embedding space. The default value is true.

  • :normalized_stress (boolean/0) - If true, normalize the stress by the sum of squared dissimilarities. Only valid if metric is false. The default value is false.

  • :eps (float/0) - Tolerance for stopping criterion. The default value is 0.001.

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

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

  • :n_init (pos_integer/0) - Number of times the embedding will be computed with different centroid seeds. The final embedding is the embedding with the lowest stress. The default value is 8.

Return Values

Returns struct with embedded data, stress value, and number of iterations for best run.

Examples

iex> x = Nx.iota({4,5})
iex> init = Nx.reverse(Nx.iota({4,2}))
iex> Scholar.Manifold.MDS.fit(x, init)
%Scholar.Manifold.MDS{
  embedding: Nx.tensor(
    [
      [11.858541488647461, 11.858541488647461],
      [3.9528470039367676, 3.9528470039367676],
      [-3.9528470039367676, -3.9528470039367676],
      [-11.858541488647461, -11.858541488647461]
    ]
  ),
  stress: Nx.tensor(
    0.0
  ),
  n_iter: Nx.tensor(
    3
  )
}

Fits MDS for sample inputs x. It is simpyfied version of fit/3 function.

Options

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

  • :metric (boolean/0) - If true, use dissimilarities as metric distances in the embedding space. The default value is true.

  • :normalized_stress (boolean/0) - If true, normalize the stress by the sum of squared dissimilarities. Only valid if metric is false. The default value is false.

  • :eps (float/0) - Tolerance for stopping criterion. The default value is 0.001.

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

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

  • :n_init (pos_integer/0) - Number of times the embedding will be computed with different centroid seeds. The final embedding is the embedding with the lowest stress. The default value is 8.

Return Values

Returns struct with embedded data, stress value, and number of iterations for best run.

Examples

iex> x = Nx.iota({4,5})
iex> key = Nx.Random.key(42)
iex> init = Nx.reverse(Nx.iota({4,3}))
iex> Scholar.Manifold.MDS.fit(x, init, num_components: 3, key: key)
%Scholar.Manifold.MDS{
  embedding: Nx.tensor(
    [
      [9.682458877563477, 9.682458877563477, 9.682458877563477],
      [3.2274858951568604, 3.2274858951568604, 3.2274858951568604],
      [-3.2274863719940186, -3.2274863719940186, -3.2274863719940186],
      [-9.682458877563477, -9.682458877563477, -9.682458877563477]
    ]
  ),
  stress: Nx.tensor(
    9.094947017729282e-12
  ),
  n_iter: Nx.tensor(
    3
  )
}