Table of Contents

Class TSNE<T>

Namespace
AiDotNet.Preprocessing.DimensionalityReduction
Assembly
AiDotNet.dll

t-Distributed Stochastic Neighbor Embedding for visualization.

public class TSNE<T> : TransformerBase<T, Matrix<T>, Matrix<T>>, IDataTransformer<T, Matrix<T>, Matrix<T>>

Type Parameters

T

The numeric type for calculations (e.g., float, double).

Inheritance
TransformerBase<T, Matrix<T>, Matrix<T>>
TSNE<T>
Implements
IDataTransformer<T, Matrix<T>, Matrix<T>>
Inherited Members

Remarks

t-SNE is a nonlinear dimensionality reduction technique well-suited for visualizing high-dimensional data in 2D or 3D space. It preserves local structure by keeping similar points close together.

The algorithm converts similarities between data points to joint probabilities and tries to minimize the divergence between probability distributions in high and low dimensional spaces.

For Beginners: t-SNE creates beautiful 2D/3D visualizations: - Points that are similar stay close together - Points that are different move apart - Great for exploring clusters in your data - Warning: Not for preserving global distances, just local neighborhoods - Warning: Results can vary with different random seeds

Constructors

TSNE(int, double, double, int, double, TSNEMetric, TSNEInitialization, int?, int[]?)

Creates a new instance of TSNE<T>.

public TSNE(int nComponents = 2, double perplexity = 30, double learningRate = 200, int nIter = 1000, double earlyExaggeration = 12, TSNEMetric metric = TSNEMetric.Euclidean, TSNEInitialization initialization = TSNEInitialization.Random, int? randomState = null, int[]? columnIndices = null)

Parameters

nComponents int

Target dimensionality (usually 2 or 3). Defaults to 2.

perplexity double

Balance between local and global structure. Defaults to 30.

learningRate double

Learning rate for optimization. Defaults to 200.

nIter int

Number of optimization iterations. Defaults to 1000.

earlyExaggeration double

Exaggeration factor for early iterations. Defaults to 12.

metric TSNEMetric

Distance metric to use. Defaults to Euclidean.

initialization TSNEInitialization

Initialization method. Defaults to Random.

randomState int?

Random seed for reproducibility.

columnIndices int[]

The column indices to use, or null for all columns.

Properties

Embedding

Gets the embedding result.

public double[,]? Embedding { get; }

Property Value

double[,]

LearningRate

Gets the learning rate.

public double LearningRate { get; }

Property Value

double

Metric

Gets the distance metric.

public TSNEMetric Metric { get; }

Property Value

TSNEMetric

NComponents

Gets the number of components (dimensions).

public int NComponents { get; }

Property Value

int

Perplexity

Gets the perplexity parameter.

public double Perplexity { get; }

Property Value

double

SupportsInverseTransform

Gets whether this transformer supports inverse transformation.

public override bool SupportsInverseTransform { get; }

Property Value

bool

Methods

FitCore(Matrix<T>)

Fits t-SNE and computes the embedding.

protected override void FitCore(Matrix<T> data)

Parameters

data Matrix<T>

GetFeatureNamesOut(string[]?)

Gets the output feature names after transformation.

public override string[] GetFeatureNamesOut(string[]? inputFeatureNames = null)

Parameters

inputFeatureNames string[]

Returns

string[]

InverseTransformCore(Matrix<T>)

Inverse transformation is not supported.

protected override Matrix<T> InverseTransformCore(Matrix<T> data)

Parameters

data Matrix<T>

Returns

Matrix<T>

TransformCore(Matrix<T>)

Returns the embedding computed during Fit.

protected override Matrix<T> TransformCore(Matrix<T> data)

Parameters

data Matrix<T>

Returns

Matrix<T>