evomap.mapping._tsne#

T-Distributed Stochastic Neighborhood Embedding, as propsoed in:

Van der Maaten, L., & Hinton, G. (2008). Visualizing data using t-SNE. Journal of machine learning research, 9(11).

Module Contents#

Classes#

TSNE

Functions#

_calc_p_matrix(X, included, input_type, perplexity)

_check_prepare_tsne(model, X)

Check and, if necessary, prepare data for t-SNE.

sqeuclidean_dist(Y)

calc_q_matrix(Y, inclusions)

Calculate Q-Matrix of joint probabilities in low-dim space.

_kl_divergence(Y, P[, compute_error, compute_grad])

_kl_divergence_grad(Y, P, Q, dist)

Calculate gradient of KL-divergence dC/dY.

cond_to_joint(P)

Take an asymmetric conditional probability matrix and convert it to a

Attributes#

EPSILON

evomap.mapping._tsne.EPSILON = 1e-12#
class evomap.mapping._tsne.TSNE(n_dims=2, perplexity=15, n_iter=2000, stop_lying_iter=250, early_exaggeration=4, initial_momentum=0.5, final_momentum=0.8, eta='auto', n_iter_check=50, init=None, verbose=0, input_type='distance', max_halves=5, tol=0.001, n_inits=1, step_size=1)[source]#
fit(X)[source]#
fit_transform(X)[source]#
evomap.mapping._tsne._calc_p_matrix(X, included, input_type, perplexity)[source]#
evomap.mapping._tsne._check_prepare_tsne(model, X)[source]#

Check and, if necessary, prepare data for t-SNE.

Parameters

model (TSNE or EvoMap) – Model object.

Returns

Prepared input data

Return type

ndarray of shape (n_samples, n_samples)

evomap.mapping._tsne.sqeuclidean_dist(Y)[source]#
evomap.mapping._tsne.calc_q_matrix(Y, inclusions)[source]#

Calculate Q-Matrix of joint probabilities in low-dim space.

Parameters
  • -- (Y {np.ndarray}) –

  • exclusions (exclusions {np.ndarray} -- condensed-dist-mat indices for) –

Returns

Q {np.ndarray} – (n,n) array of joint probabilities in low-dim space. dist {np.ndarray} – (n,n) array of squared euclidean distances

evomap.mapping._tsne._kl_divergence(Y, P, compute_error=True, compute_grad=True)[source]#
evomap.mapping._tsne._kl_divergence_grad(Y, P, Q, dist)[source]#

Calculate gradient of KL-divergence dC/dY.

Parameters
  • -- (Y {np.ndarray}) –

  • probabilities (Q {np.ndarray} -- condensed-matrix of joint) –

  • probabilities

  • distances (dist {np.ndarray} -- condensed-matrix of sq.euclidean) –

Returns

dY {np.ndarray} – (n,2) array of gradient values

evomap.mapping._tsne.cond_to_joint(P)[source]#

Take an asymmetric conditional probability matrix and convert it to a symmetric joint probability matrix.

Symmetrizes and normalizes the matrix.