jml.manifold
Class Manifold

java.lang.Object
  extended by jml.manifold.Manifold

public class Manifold
extends java.lang.Object


Constructor Summary
Manifold()
           
 
Method Summary
static org.apache.commons.math.linear.RealMatrix adjacency(org.apache.commons.math.linear.RealMatrix X, java.lang.String type, double param, java.lang.String distFunc)
          Compute the symmetric adjacency matrix of the data set represented as a real data matrix X.
static org.apache.commons.math.linear.RealMatrix adjacencyDirected(org.apache.commons.math.linear.RealMatrix X, java.lang.String type, double param, java.lang.String distFunc)
          Compute the directed adjacency matrix of the data set represented as a real data matrix X.
static org.apache.commons.math.linear.RealMatrix calcLLR(org.apache.commons.math.linear.RealMatrix X, double NN, java.lang.String distFunc, java.lang.String kernelType, double kernelParam, double lambda)
          Compute local learning regularization matrix.
static org.apache.commons.math.linear.RealMatrix cosine(org.apache.commons.math.linear.RealMatrix A, org.apache.commons.math.linear.RealMatrix B)
          Compute the cosine distance matrix between column vectors in matrix A and column vectors in matrix B.
static org.apache.commons.math.linear.RealMatrix euclidean(org.apache.commons.math.linear.RealMatrix A, org.apache.commons.math.linear.RealMatrix B)
          Compute the Euclidean distance matrix between column vectors in matrix A and column vectors in matrix B.
static org.apache.commons.math.linear.RealMatrix laplacian(org.apache.commons.math.linear.RealMatrix X, java.lang.String type, GraphOptions options)
          Calculate the graph Laplacian of the adjacency graph of a data set represented as columns of a matrix X.
static void main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Manifold

public Manifold()
Method Detail

main

public static void main(java.lang.String[] args)
Parameters:
args -

laplacian

public static org.apache.commons.math.linear.RealMatrix laplacian(org.apache.commons.math.linear.RealMatrix X,
                                                                  java.lang.String type,
                                                                  GraphOptions options)
Calculate the graph Laplacian of the adjacency graph of a data set represented as columns of a matrix X.

Parameters:
X - data matrix with each column being a sample
type - graph type, either "nn" or "epsballs"
options - data structure containing the following fields NN - integer if type is "nn" (number of nearest neighbors), or size of "epsballs" DISTANCEFUNCTION - distance function used to make the graph WEIGHTTYPPE = "binary" | "distance" | "heat" | "inner" WEIGHTPARAM = width for heat kernel NORMALIZE = 0 | 1 whether to return normalized graph Laplacian or not
Returns:
a sparse symmetric N x N matrix

adjacency

public static org.apache.commons.math.linear.RealMatrix adjacency(org.apache.commons.math.linear.RealMatrix X,
                                                                  java.lang.String type,
                                                                  double param,
                                                                  java.lang.String distFunc)
Compute the symmetric adjacency matrix of the data set represented as a real data matrix X. The diagonal elements of the sparse symmetric adjacency matrix are all zero indicating that a sample should not be a neighbor of itself. Note that in some cases, neighbors of a sample may coincide with the sample itself, we set eps for those entries in the sparse symmetric adjacency matrix.

Parameters:
X - data matrix with each column being a feature vector
type - graph type, either "nn" or "epsballs" ("eps")
param - integer if type is "nn", real number if type is "epsballs" ("eps")
distFunc - function mapping a (D x M) and a (D x N) matrix to an M x N distance matrix (D: dimensionality) either "euclidean" or "cosine"
Returns:
a sparse symmetric N x N matrix of distances between the adjacent points

adjacencyDirected

public static org.apache.commons.math.linear.RealMatrix adjacencyDirected(org.apache.commons.math.linear.RealMatrix X,
                                                                          java.lang.String type,
                                                                          double param,
                                                                          java.lang.String distFunc)
Compute the directed adjacency matrix of the data set represented as a real data matrix X. The diagonal elements of the sparse directed adjacency matrix are all zero indicating that a sample should not be a neighbor of itself. Note that in some cases, neighbors of a sample may coincide with the sample itself, we set eps for those entries in the sparse directed adjacency matrix.

Parameters:
X - data matrix with each column being a feature vector
type - graph type, either "nn" or "epsballs" ("eps")
param - integer if type is "nn", real number if type is "epsballs" ("eps")
distFunc - function mapping a (D x M) and a (D x N) matrix to an M x N distance matrix (D: dimensionality) either "euclidean" or "cosine"
Returns:
a sparse N x N matrix of distances between the adjacent points, not necessarily symmetric

cosine

public static org.apache.commons.math.linear.RealMatrix cosine(org.apache.commons.math.linear.RealMatrix A,
                                                               org.apache.commons.math.linear.RealMatrix B)
Compute the cosine distance matrix between column vectors in matrix A and column vectors in matrix B.

Parameters:
A - data matrix with each column being a feature vector
B - data matrix with each column being a feature vector
Returns:
an n_A X n_B matrix with its (i, j) entry being the cosine distance between i-th feature vector in A and j-th feature vector in B, i.e., ||A(:, i) - B(:, j)|| = 1 - A(:, i)' * B(:, j) / || A(:, i) || * || B(:, j)||

euclidean

public static org.apache.commons.math.linear.RealMatrix euclidean(org.apache.commons.math.linear.RealMatrix A,
                                                                  org.apache.commons.math.linear.RealMatrix B)
Compute the Euclidean distance matrix between column vectors in matrix A and column vectors in matrix B.

Parameters:
A - data matrix with each column being a feature vector
B - data matrix with each column being a feature vector
Returns:
an n_A X n_B matrix with its (i, j) entry being Euclidean distance between i-th feature vector in A and j-th feature vector in B, i.e., || X(:, i) - Y(:, j) ||_2

calcLLR

public static org.apache.commons.math.linear.RealMatrix calcLLR(org.apache.commons.math.linear.RealMatrix X,
                                                                double NN,
                                                                java.lang.String distFunc,
                                                                java.lang.String kernelType,
                                                                double kernelParam,
                                                                double lambda)
Compute local learning regularization matrix. Local learning regularization only depends on kernel selection, distance function, and neighborhood size.

Parameters:
X - data matrix with each column being a feature vector
NN - number of nearest neighbor
distFunc - function mapping a (D x M) and a (D x N) matrix to an M x N distance matrix (D: dimensionality) either "euclidean" or "cosine"
kernelType - 'linear' | 'poly' | 'rbf' | 'cosine'
kernelParam - -- | degree | sigma | --
lambda - graph regularization parameter
Returns:
local learning regularization matrix