Class GaussianAffinityMatrixBuilder<O>

  • Type Parameters:
    O - Vector type
    All Implemented Interfaces:
    AffinityMatrixBuilder<O>
    Direct Known Subclasses:
    PerplexityAffinityMatrixBuilder

    @Reference(authors="G. Hinton, S. Roweis",
               title="Stochastic Neighbor Embedding",
               booktitle="Advances in Neural Information Processing Systems 15",
               url="http://papers.nips.cc/paper/2276-stochastic-neighbor-embedding",
               bibkey="DBLP:conf/nips/HintonR02")
    public class GaussianAffinityMatrixBuilder<O>
    extends java.lang.Object
    implements AffinityMatrixBuilder<O>
    Compute the affinity matrix for SNE and tSNE using a Gaussian distribution with a constant sigma.

    Reference:

    G. Hinton, S. Roweis
    Stochastic Neighbor Embedding
    Advances in Neural Information Processing Systems 15

    Since:
    0.7.5
    Author:
    Erich Schubert
    • Field Detail

      • LOG

        private static final Logging LOG
        Class logger.
      • MIN_PIJ

        protected static final double MIN_PIJ
        Minimum value for pij entries (even when duplicate)
        See Also:
        Constant Field Values
      • distance

        protected Distance<? super O> distance
        Input distance function.
      • sigma

        protected double sigma
        Kernel bandwidth sigma.
    • Constructor Detail

      • GaussianAffinityMatrixBuilder

        public GaussianAffinityMatrixBuilder​(Distance<? super O> distance,
                                             double sigma)
        Constructor.
        Parameters:
        distance - Distance function
        sigma - Gaussian kernel bandwidth
    • Method Detail

      • buildDistanceMatrix

        protected double[][] buildDistanceMatrix​(ArrayDBIDs ids,
                                                 DistanceQuery<?> dq)
        Build a distance matrix of squared distances.
        Parameters:
        ids - DBIDs
        dq - Distance query
        Returns:
        Distance matrix
      • computePij

        protected static double[][] computePij​(double[][] dist,
                                               double sigma,
                                               double initialScale)
        Compute the pij from the distance matrix.
        Parameters:
        dist - Distance matrix.
        sigma - Kernel bandwidth sigma
        initialScale - Initial scale
        Returns:
        Affinity matrix pij
      • computeH

        protected static double computeH​(int i,
                                         double[] dist_i,
                                         double[] pij_i,
                                         double mbeta)
        Compute H (observed perplexity) for row i, and the row pij_i.
        Parameters:
        i - Current point i (entry i will be ignored)
        dist_i - Distance matrix row (input)
        pij_i - Row pij[i] (output)
        mbeta - -1. / (2 * sigma * sigma)
        Returns:
        Observed perplexity