View Source Scholar.Manifold.Trimap (Scholar v0.3.1)
TriMap: Large-scale Dimensionality Reduction Using Triplets.
TriMap is a dimensionality reduction method that uses triplet constraints to form a low-dimensional embedding of a set of points. The triplet constraints are of the form "point i is closer to point j than point k". The triplets are sampled from the high-dimensional representation of the points and a weighting scheme is used to reflect the importance of each triplet.
TriMap provides a significantly better global view of the data than the other dimensionality reduction methods such t-SNE, LargeVis.
The global structure includes relative distances of the clusters, multiple scales in the data, and the existence of possible outliers. We define a global score to quantify the quality of an embedding in reflecting the global structure of the data.
Based on: https://github.com/google-research/google-research/blob/master/trimap/trimap.py Source: https://arxiv.org/pdf/1910.00204.pdf
Summary
Functions
Embeds the given inputs using the TriMap algorithm.
Functions
Embeds the given inputs using the TriMap algorithm.
Options
:num_components
(pos_integer/0
) - Dimension of the embedded space. The default value is2
.:num_inliers
(pos_integer/0
) - Number of inliners to sample. The default value is10
.:num_outliers
(pos_integer/0
) - Number of outliers to sample. The default value is5
.:num_random
(pos_integer/0
) - Number of random triplets to sample. The default value is3
.:weight_temp
(float/0
) - Temperature for the tempered log. The default value is0.5
.:learning_rate
(float/0
) - Learning rate. The default value is0.1
.:num_iters
(pos_integer/0
) - Number of iterations. The default value is400
.:init_embedding_type
- Method to initialize the embedding. 0 for PCA, 1 for random. The default value is0
.:key
- Random key used in Trimap. If the key is not provided, it is set toNx.Random.key(System.system_time())
.:triplets
(term/0
) - Triplets to use in the Trimap algorithm.:weights
(term/0
) - Weights to use in the Trimap algorithm.:init_embeddings
(term/0
) - Initial embeddings to use in the Trimap algorithm.:metric
- Metric used to compute the distances. The default value is:squared_euclidean
.:knn_algorithm
- Algorithm used to compute the nearest neighbors. Possible values::nndescent
- Nearest Neighbors Descent. SeeScholar.Neighbors.NNDescent
for more details.:large_vis
- LargeVis algorithm. SeeScholar.Neighbors.LargeVis
for more details.:brute
- Brute force algorithm. SeeScholar.Neighbors.BruteKNN
for more details.:auto
- Automatically selects the algorithm based on the number of points.
The default value is
:auto
.
Examples
iex> {inputs, key} = Nx.Random.uniform(Nx.Random.key(42), shape: {30, 5})
iex> Scholar.Manifold.Trimap.transform(inputs, num_components: 2, num_inliers: 3, num_outliers: 1, key: key, knn_algorithm: :nndescent)