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 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.fit
— Methodfit(NonlinearDimensionalityReduction, X)
Perform model fitting given the data X
StatsAPI.predict
— Methodpredict(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.
There are auxiliary methods that allow to inspect properties of the constructed model.
Base.size
— Methodsize(R::NonlinearDimensionalityReduction)
Returns a tuple of the input and reduced space dimensions for the model R
LinearAlgebra.eigvals
— Methodeigvals(R::NonlinearDimensionalityReduction)
Returns eignevalues of the reduced space reporesentation for the model R
Graphs.vertices
— Methodvertices(R::NonlinearDimensionalityReduction)
Returns vertices of largest connected component in the model R
.
Graphs.neighbors
— Methodneighbors(R::NonlinearDimensionalityReduction)
Returns the number of nearest neighbors used for aproximate local subspace
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.
ManifoldLearning.AbstractNearestNeighbors
— TypeAbstractNearestNeighbors
Abstract type for nearest neighbor plug-in implementations.
The above interface requires implementation of the following methods:
ManifoldLearning.knn
— Methodknn(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.
ManifoldLearning.inrange
— Methodinrange(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.
Following auxiliary methods available for any implementation of AbstractNearestNeighbors
-derived type:
ManifoldLearning.adjacency_list
— Methodadjacency_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, thenk
nearest neighbors are use for construction. - If
k
is a real number, then radiusk
neighborhood is used for construction.
ManifoldLearning.adjacency_matrix
— Methodadjacency_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, thenk
nearest neighbors are use for construction. - If
k
is a real number, then radiusk
neighborhood is used for construction.
The default implementation uses inefficient $O(n^2)$ algorithm for nearest neighbors calculations.
ManifoldLearning.BruteForce
— TypeBruteForce
Calculate nearest neighborhoods using pairwise distance matrix.