Skip to content

Instantly share code, notes, and snippets.

@lovit
Created December 10, 2019 14:27
Show Gist options
  • Save lovit/eb6ccee7dc37b225706e711bf774c77f to your computer and use it in GitHub Desktop.
Save lovit/eb6ccee7dc37b225706e711bf774c77f to your computer and use it in GitHub Desktop.
UMAP supervised embedding example
from sklearn.datasets import make_classification

X, y = make_classification(
    n_samples=50000, n_features=200, n_informative=5, 
    n_redundant=0, n_clusters_per_class=10, weights=[0.80],
    flip_y=0.05, class_sep=3.5, random_state=42
)

# standard normalization: (x - mean) / std
X = StandardScaler().fit_transform(X)

unsup_embed = UMAP().fit_transform(X)
sup_embed_umap = UMAP().fit_transform(X, y=y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment