Skip to content
/ t-SNE Public

A python pacakge for t-SNE dimensionality reduction.

Notifications You must be signed in to change notification settings

epswartz/t-SNE

Repository files navigation

t-SNE

A python package and analysis of the t-SNE dimensionality reduction technique. t-SNE Animation

Installation

You can install the package from pip:

pip install simple_tsne

Usage

The core functionality of the package lives in the tsne function.

The following example runs tsne on the MNIST dataset:

from simple_tsne import tsne, momentum_func
from sklearn.datasets import load_digits
import matplotlib.pyplot as plt

digits, digit_class = load_digits(return_X_y=True)
low_dim = tsne(
    data=digits, # Data is mxn numpy array, each row a point
    n_components=2, # Number of dim to embed to
    perp=30, # Perplexity (higher for more spread out data)
    n_iter=500, # Iterations to run t-SNE for
    lr=100, # Learning rate
    momentum_fn=momentum_func, # Function returning momentum coefficient, this one is the default update schedule
    pbar=True, # Show progress bar
    random_state=42 # Seed for random initialization
)

# Plot results
plt.figure()
plt.scatter(low_dim[:,0], low_dim[:,1], c=digit_class)
plt.show()

About

A python pacakge for t-SNE dimensionality reduction.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages