Programming interface

The interface of manifold learning methods in this packages is partially adopted from the packages StatsAPI, MultivariateStats.jl and Graphs.jl. You can implement additional dimensionality reduction algorithms by implementing the following interface.

Dimensionality Reduction

The following functions are currently available from the interface. NonlinearDimensionalityReduction is an abstract type required for all implemented algorithms models.

Missing docstring.

Missing docstring for ManifoldLearning.NonlinearDimensionalityReduction. Check Documenter's build log for details.

For performing the data dimensionality reduction procedure, a model of the data is constructed by calling fit method, and the transformation of the data given the model is done by predict method.

StatsAPI.fitMethod
fit(NonlinearDimensionalityReduction, X)

Perform model fitting given the data X

source
StatsAPI.predictMethod
predict(R::NonlinearDimensionalityReduction)

Returns a reduced space representation of the data given the model R inform of the projection matrix (of size $(d, n)$), where d is a dimension of the reduced space and n in the number of the observations. Each column of the projection matrix corresponds to an observation in projected reduced space.

source

There are auxiliary methods that allow to inspect properties of the constructed model.

Base.sizeMethod
size(R::NonlinearDimensionalityReduction)

Returns a tuple of the input and reduced space dimensions for the model R

source
LinearAlgebra.eigvalsMethod
eigvals(R::NonlinearDimensionalityReduction)

Returns eignevalues of the reduced space reporesentation for the model R

source
Graphs.verticesMethod
vertices(R::NonlinearDimensionalityReduction)

Returns vertices of largest connected component in the model R.

source
Graphs.neighborsMethod
neighbors(R::NonlinearDimensionalityReduction)

Returns the number of nearest neighbors used for aproximate local subspace

source

Nearest Neighbors

An additional interface is available for creating an implementation of a nearest neighbors algorithm, which is commonly used for dimensionality reduction methods. Use AbstractNearestNeighbors abstract type to derive a type for a new implementation.

The above interface requires implementation of the following methods:

ManifoldLearning.knnMethod
knn(NN::AbstractNearestNeighbors, X::AbstractVecOrMat{T}, k::Integer; kwargs...) -> (I,D)

Returns (k, n)-matrices of point indexes and distances of k nearest neighbors for points in the (m,n)-matrix X given the NN object.

source
ManifoldLearning.inrangeMethod
inrange(NN::AbstractNearestNeighbors, X::AbstractVecOrMat{T}, r::Real; kwargs...) -> (I,D)

Returns collections of point indexes and distances in radius r of points in the (m,n)-matrix X given the NN object.

source

Following auxiliary methods available for any implementation of AbstractNearestNeighbors-derived type:

ManifoldLearning.adjacency_listMethod
adjacency_list(NN::AbstractNearestNeighbors, X::AbstractVecOrMat{T}, k::Real; kwargs...) -> (A, W)

Perform construction of an adjacency list A with corresponding weights W from the points in X given the NN object.

  • If k is a positive integer, then k nearest neighbors are use for construction.
  • If k is a real number, then radius k neighborhood is used for construction.
source
ManifoldLearning.adjacency_matrixMethod
adjacency_matrix(NN::AbstractNearestNeighbors, X::AbstractVecOrMat{T}, k::Real; kwargs...) -> A

Perform construction of a weighted adjacency distance matrix A from the points in X given the NN object.

  • If k is a positive integer, then k nearest neighbors are use for construction.
  • If k is a real number, then radius k neighborhood is used for construction.
source

The default implementation uses inefficient $O(n^2)$ algorithm for nearest neighbors calculations.