Last active
April 7, 2021 08:34
-
-
Save MathiasGruber/dc344907ce64ae318da0c5eaf0301027 to your computer and use it in GitHub Desktop.
Running t-SNE, UMAP, TriMAP and PaCMAP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import trimap | |
import umap | |
import pacmap | |
from sklearn.manifold import TSNE | |
# Read data | |
df = pd.read_csv('your_dataset.csv') | |
# Algorithms to test | |
algorithms = { | |
't-SNE': TSNE(), | |
'UMAP': umap.UMAP(), | |
'TriMAP': trimap.TRIMAP(), | |
'PaCMAP': pacmap.PaCMAP() | |
} | |
# Create embeddings for each algorithm & save fitting time | |
results = {} | |
for name, algorithm in algorithms.items(): | |
# Calculate embeddings | |
t0 = time.time() | |
embedding = algorithm.fit_transform(df.values) | |
# Store results & runtime | |
results[name] = { | |
'embedding': pd.DataFrame(embedding, columns=['x', 'y']), | |
'time': time.time() - t0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment