Documentation ¶
Overview ¶
Package tsne implements t-Distributed Stochastic Neighbor Embedding (t-SNE), a prize-winning technique for dimensionality reduction particularly well suited for visualizing high-dimensional datasets.
Index ¶
Constants ¶
const ( Epsilon = 1e-7 GreaterThanZero = 1e-12 EntropyTolerance = 1e-5 MaxBinarySearchSteps = 50 InitialStandardDeviation = 1e-4 )
Variables ¶
This section is empty.
Functions ¶
func RandNormal ¶
RandNormal samples from a Gaussian distribution with the specified mean and standard deviation.
func SquaredDistanceMatrix ¶
SquaredDistanceMatrix computes the squared distance matrix for row vectors in X. Returns a matrix where the {i, j}-th element is the squared euclidean distance between the i-th and j-th rows in X.
D(x, y)^2 = ∥y – x∥^2 = x'x + y'y – 2 x'y
Types ¶
type TSNE ¶
type TSNE struct { P *mat.Dense // Matrix of pairwise affinities in the high dimensional space (Gaussian kernel) Q *mat.Dense // Matrix of pairwise affinities in the low dimensional space (t-Student kernel) Y *mat.Dense // The output embedding with dimsOut dimensions PlogP float64 // The constant portion of the KL divergence, computed only once // contains filtered or unexported fields }
TSNE is a t-Distributed Stochastic Neighbor Embedding (t-SNE) dimensionality reduction object.
func NewTSNE ¶
NewTSNE creates and returns a new t-SNE dimensionality reductor with the specified parameters.
func (*TSNE) EmbedData ¶
func (tsne *TSNE) EmbedData(X mat.Matrix, stepFunc func(iter int, divergence float64, embedding mat.Matrix) bool) mat.Matrix
EmbedData initializes the pairwise affinity matrix P with the similarity probabilities calculated based on the provided data matrix and runs t-SNE. It returns the generated embedding.
func (*TSNE) EmbedDistances ¶
func (tsne *TSNE) EmbedDistances(D mat.Matrix, stepFunc func(iter int, divergence float64, embedding mat.Matrix) bool) mat.Matrix
InitDistances initializes the pairwise affinity matrix P with the similarity probabilities calculated based on the provided (squared) distance matrix and runs t-SNE. It returns the generated embedding.