O - Object type@Reference(authors="L. J. P. van der Maaten", title="Accelerating t-SNE using Tree-Based Algorithms", booktitle="Journal of Machine Learning Research 15", url="http://dl.acm.org/citation.cfm?id=2697068", bibkey="DBLP:journals/jmlr/Maaten14") public class NearestNeighborAffinityMatrixBuilder<O> extends PerplexityAffinityMatrixBuilder<O>
Reference:
 L. J. P. van der Maaten
 Accelerating t-SNE using Tree-Based Algorithms
 Journal of Machine Learning Research 15
 
TODO: this implementation currently differs in one major point: we do not symmetrize the sparse \(p_{ij}\) matrix.
| Modifier and Type | Class and Description | 
|---|---|
static class  | 
NearestNeighborAffinityMatrixBuilder.Parameterizer<O>
Parameterization class. 
 | 
| Modifier and Type | Field and Description | 
|---|---|
private static Logging | 
LOG
Class logger. 
 | 
protected int | 
numberOfNeighbours
Number of neighbors to use. 
 | 
distanceFunction, MIN_PIJ, perplexity, PERPLEXITY_ERROR, PERPLEXITY_MAXITERsigma| Constructor and Description | 
|---|
NearestNeighborAffinityMatrixBuilder(DistanceFunction<? super O> distanceFunction,
                                    double perplexity)
Constructor. 
 | 
NearestNeighborAffinityMatrixBuilder(DistanceFunction<? super O> distanceFunction,
                                    double perplexity,
                                    int neighbors)
Constructor. 
 | 
| Modifier and Type | Method and Description | 
|---|---|
<T extends O> | 
computeAffinityMatrix(Relation<T> relation,
                     double initialScale)
Compute the affinity matrix. 
 | 
protected static double | 
computeH(DoubleArray dist_i,
        double[] pij_row,
        double mbeta)
Compute H (observed perplexity) for row i, and the row pij_i. 
 | 
protected void | 
computePij(DBIDRange ids,
          KNNQuery<?> knnq,
          boolean square,
          int numberOfNeighbours,
          double[][] pij,
          int[][] indices,
          double initialScale)
Compute the sparse pij using the nearest neighbors only. 
 | 
protected static double | 
computeSigma(int i,
            DoubleArray pij_row,
            double perplexity,
            double log_perp,
            double[] pij_i)
Compute row pij[i], using binary search on the kernel bandwidth sigma to
 obtain the desired perplexity. 
 | 
protected static int | 
containsIndex(int[] is,
             int i)
Check if the index array contains  
i. | 
protected void | 
convertNeighbors(DBIDRange ids,
                DBIDRef ix,
                boolean square,
                KNNList neighbours,
                DoubleArray dist,
                IntegerArray ind)
Load a neighbor query result into a double and and integer array, also
 removing the query point. 
 | 
computePi, computePij, estimateInitialBeta, getInputTypeRestrictionbuildDistanceMatrix, computeHprivate static final Logging LOG
protected int numberOfNeighbours
public NearestNeighborAffinityMatrixBuilder(DistanceFunction<? super O> distanceFunction, double perplexity)
distanceFunction - Distance functionperplexity - Desired perplexity (will use 3*perplexity neighbors)public NearestNeighborAffinityMatrixBuilder(DistanceFunction<? super O> distanceFunction, double perplexity, int neighbors)
distanceFunction - Distance functionperplexity - Desired perplexityneighbors - Number of neighbors to usepublic <T extends O> AffinityMatrix computeAffinityMatrix(Relation<T> relation, double initialScale)
AffinityMatrixBuildercomputeAffinityMatrix in interface AffinityMatrixBuilder<O>computeAffinityMatrix in class PerplexityAffinityMatrixBuilder<O>T - Relation typerelation - Data relationinitialScale - initial scaleprotected void computePij(DBIDRange ids, KNNQuery<?> knnq, boolean square, int numberOfNeighbours, double[][] pij, int[][] indices, double initialScale)
ids - ID rangeknnq - kNN querysquare - Use squared distancesnumberOfNeighbours - Number of neighbors to getpij - Output of distancesindices - Output of indexesinitialScale - Initial scaling factorprotected void convertNeighbors(DBIDRange ids, DBIDRef ix, boolean square, KNNList neighbours, DoubleArray dist, IntegerArray ind)
ids - Indexesix - Current Objectsquare - Use squared distancesneighbours - Neighbor listdist - Output distance arrayind - Output index arrayprotected static double computeSigma(int i,
                                     DoubleArray pij_row,
                                     double perplexity,
                                     double log_perp,
                                     double[] pij_i)
i - Current pointpij_row - Distance matrix row pij[i]perplexity - Desired perplexitylog_perp - Log of desired perplexitypij_i - Output rowprotected static double computeH(DoubleArray dist_i, double[] pij_row, double mbeta)
dist_i - Distances to neighborspij_row - Row pij[i] (output)mbeta - -1. / (2 * sigma * sigma)protected static int containsIndex(int[] is,
                                   int i)
i.
 
 TODO: sort arrays, use binary search!is - Array to searchi - Index to search-1 if not found.Copyright © 2019 ELKI Development Team. License information.