tsne

package module
v0.0.0-...-2250969 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2022 License: BSD-3-Clause Imports: 4 Imported by: 5

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

View Source
const (
	Epsilon                  = 1e-7
	GreaterThanZero          = 1e-12
	EntropyTolerance         = 1e-5
	MaxBinarySearchSteps     = 50
	InitialStandardDeviation = 1e-4
)

Variables

This section is empty.

Functions

func Diagonal

func Diagonal(a mat.Matrix) mat.Vector

Diagonal returns the diagonal elements of the specified matrix as a Vector.

func RandNormal

func RandNormal(mu, std float64) float64

RandNormal samples from a Gaussian distribution with the specified mean and standard deviation.

func SquaredDistanceMatrix

func SquaredDistanceMatrix(X mat.Matrix) mat.Matrix

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

func NewTSNE(dimensionsOut int, perplexity, learningRate float64, maxIter int, verbose bool) *TSNE

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL