nuget server logo nuget api documents
↑

API Docs / Microsoft.VisualBasic.DataMining.UMAP / Umap

Umap

Full name Microsoft.VisualBasic.DataMining.UMAP.Umap Assembly Microsoft.VisualBasic.DataMining.UMAP Members 22

UMAP: Uniform Manifold Approximation and Projection for Dimension Reduction

00 Remarks

https://github.com/curiosity-ai/umap-sharp

01 Syntax

Microsoft.VisualBasic.DataMining.UMAP.Umap

02 Methods

NameOverloadsSummary
.ctor 1
InitializeFit 1 Initializes fit by computing KNN and a fuzzy simplicial set, as well as initializing the projected embeddings.
GetEmbedding 1 get projection result
GetNEpochs 1 Gets the number of epochs for optimizing the projection - NOTE: This heuristic differs from the python version
GetEmbeddingSpan 1 Get the underlying embedding vector as a Span view for the SGD optimization.
FuzzySimplicialSet 1 Given a set of data X, a neighborhood size, and a measure of distance compute the fuzzy simplicial set(here represented as a fuzzy graph in the form of a sparse matrix) associate…
InitializeSimplicialSetEmbedding 1 Initialize a fuzzy simplicial set embedding, using a specified initialisation method and then minimizing the fuzzy set cross entropy between the 1-skeletons of the high and low d…
FindABParams 1 Fit a, b params for the differentiable curve used in lower dimensional fuzzy simplicial complex construction.
Step 1 Manually step through the optimization process one epoch at a time
OptimizeLayoutStep 1 Improve an embedding using stochastic gradient descent to minimize the fuzzy set cross entropy between the 1-skeletons of the high dimensional and low dimensional fuzzy simplicia…
RunIterate 1 run the SGD iteration of the i th edge of the epoch n

03 Fields

NameOverloadsSummary
_negativeSampleRate 1 The number of negative samples to select per positive sample in the optimization process.
_gradientClipValue 1 the gradient clipping value of the SGD optimization step
_initialEmbeddingRange 1 the value range [-a, a] of the uniformly distributed random initialization of the embedding
_moveOther 1 move the other vertex of the edge while doing the SGD optimization?
_epochsSchedule 1 the number-of-epochs heuristic of the SGD optimization
_parallelism 1 the parallelism configuration of the whole UMAP pipeline
_optimizationState 1 graph data: + head source index + tail target index + value edge weight
_kdTreeKNNEngine 1 run knn search via kd-tree as mectric engine?
_graph 1 Internal graph connectivity representation
_knn 1 KNN state (can be precomputed and supplied via initializeFit)
_embedding 1 Projected embedding

04 Members

method .ctor #
#ctor(DistanceCalculation, IProvideRandomValues, Int32, Int32, Double, Int32, Double, Nullable(Of Int32), Nullable(Of Double), Boolean, Double, Double, Double, Double, Double, SetProgressEventHandler, Int32, EpochSchedule, Double, Double, Boolean, Int32, Int32, Int32, Double, Double, Boolean, Int32, ParallelConfig)
Parameters
NameTypeDescription
distanceDistanceCalculation

-

randomIProvideRandomValues

-

dimensionsInt32

-

numberOfNeighborsInt32

-

localConnectivityDouble

-

KnnIterInt32

-

bandwidthDouble

-

customNumberOfEpochsNullable(Of Int32)

a fixed number of the SGD epochs, the epochsSchedule heuristic is used when this parameter value is not set.

customMapCutoffNullable(Of Double)

cutoff value in range [0,1]

progressReporterBoolean

-

negativeSampleRateDouble

The number of negative samples to select per positive sample in the optimization process (default 5).

epochsScheduleDouble

the number-of-epochs heuristic that is used by the SGD optimization, the default schedule is: n<=2500 -> 500, n<=5000 -> 400, n<=7500 -> 300 and n>7500 -> 200.

gradientClipValueDouble

the gradient clipping value of the SGD optimization step (default 4.0)

initialEmbeddingRangeDouble

the value range [-a, a] of the uniformly distributed random initialization of the embedding (default 10).

moveOtherDouble

move the other vertex of the edge while doing the SGD optimization? (default TRUE)

nTreesSetProgressEventHandler

the number of the random projection trees of the rp-forest, the adaptive formula 5 + round(sqrt(n) / 20) is used when this parameter value is less than or equals to zero.

leafSizeInt32

the max size of the leaf node of the random projection tree, the adaptive formula max(10, k) is used when this parameter value is less than or equals to zero.

maxCandidatesEpochSchedule

the max number of the candidate neighbours of each vertex that is used by the nearest neighbour descent (default 50).

nnDescentDeltaDouble

the early stop threshold of the nearest neighbour descent (default 0.001).

nnDescentRhoDouble

the sample rate of the nearest neighbour descent, a lower value means a faster but more approximate neighbour graph (default 0.5).

rpTreeInitBoolean

init the neighbour graph via the random projection forest? (default TRUE)

nnDescentItersInt32

the number of the iterations of the nearest neighbour descent, the adaptive formula max(5, floor(round(log2(n)))) is used when this parameter value is less than or equals to zero.

parallelismInt32

the parallelism configuration of the whole UMAP pipeline, the ParallelConfig.Sequential is used when this parameter value is not set.

method InitializeFit #
InitializeFit(Double()())

Initializes fit by computing KNN and a fuzzy simplicial set, as well as initializing the projected embeddings. Sets the optimization state ahead of optimization steps.

Returns the number of epochs to be used for the SGD optimization.

method GetEmbedding #
GetEmbedding

get projection result

method GetNEpochs #
GetNEpochs

Gets the number of epochs for optimizing the projection - NOTE: This heuristic differs from the python version

Remarks

the threshold/epoch value pairs are configurable now via the EpochSchedule object, the default schedule is completely the same as the original hardcoded heuristic.

method GetEmbeddingSpan #
GetEmbeddingSpan

Get the underlying embedding vector as a Span view for the SGD optimization.

Returns

a span view which is bound to the shared embedding vector, the write operation of the span view is directly applied to the embedding vector.

method FuzzySimplicialSet #
FuzzySimplicialSet(Double()(), Double)

Given a set of data X, a neighborhood size, and a measure of distance compute the fuzzy simplicial set(here represented as a fuzzy graph in the form of a sparse matrix) associated to the data. This is done by locally approximating geodesic distance at each point, creating a fuzzy simplicial set for each such point, and then combining all the local fuzzy simplicial sets into a global one via a fuzzy union.

method InitializeSimplicialSetEmbedding #
InitializeSimplicialSetEmbedding

Initialize a fuzzy simplicial set embedding, using a specified initialisation method and then minimizing the fuzzy set cross entropy between the 1-skeletons of the high and low dimensional fuzzy simplicial sets.

method FindABParams #
FindABParams(Double, Double)

Fit a, b params for the differentiable curve used in lower dimensional fuzzy simplicial complex construction. We want the smooth curve (from a pre-defined family with simple gradient) that best matches an offset exponential decay.

Remarks

the Levenberg-Marquardt algorithm that is required by the curve fitting is implemented inside the ABParams module, so that any combination of the spread/minDist parameters is supported now (previously an ArgumentException will be thrown for any non-default configuration).

the result of the default configuration (spread = 1, minDist = 0.1) is still the original hardcoded constant, so that the default behaviour is not changed at all.

Parameters
NameTypeDescription
spreadDouble

the effective scale of the embedded points

minDistDouble

the effective minimum distance between the embedded points

method Step #
Step

Manually step through the optimization process one epoch at a time

method OptimizeLayoutStep #
OptimizeLayoutStep(Int32)

Improve an embedding using stochastic gradient descent to minimize the fuzzy set cross entropy between the 1-skeletons of the high dimensional and low dimensional fuzzy simplicial sets.

In practice this is done by sampling edges based on their membership strength(with the (1-p) terms coming from negative sampling similar to word2vec).

method RunIterate #
RunIterate(Int32, Int32, Double, Span(Of Double))

run the SGD iteration of the i th edge of the epoch n

Parameters
NameTypeDescription
iInt32

the index of the edge

nInt32

the current epoch

clipValueDouble

the gradient clipping value

embeddingSpanSpan(Of Double)

a span view which is bound to the shared embedding vector, each worker thread of the parallel SGD creates its own view via Umap.GetEmbeddingSpan().

field _negativeSampleRate #
_negativeSampleRate

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.

field _gradientClipValue #
_gradientClipValue

the gradient clipping value of the SGD optimization step

field _initialEmbeddingRange #
_initialEmbeddingRange

the value range [-a, a] of the uniformly distributed random initialization of the embedding

field _moveOther #
_moveOther

move the other vertex of the edge while doing the SGD optimization?

field _epochsSchedule #
_epochsSchedule

the number-of-epochs heuristic of the SGD optimization

field _parallelism #
_parallelism

the parallelism configuration of the whole UMAP pipeline

field _optimizationState #
_optimizationState

graph data:

  • head source index
  • tail target index
  • value edge weight
field _kdTreeKNNEngine #
_kdTreeKNNEngine

run knn search via kd-tree as mectric engine?

field _graph #
_graph

Internal graph connectivity representation

field _knn #
_knn

KNN state (can be precomputed and supplied via initializeFit)

field _embedding #
_embedding

Projected embedding