CoCalc Public Filesumap.ipynbOpen with one click!
Author: Harald Schilly
Views : 469
Compute Environment: Ubuntu 18.04 (Deprecated)


Testing iris dataset:

Kernel: Python 3 (Ubuntu Linux)

In [1]:
import numpy as np from sklearn.datasets import load_iris, load_digits from sklearn.model_selection import train_test_split import matplotlib.pyplot as plt import seaborn as sns import pandas as pd sns.set(style='white', context='notebook', rc={'figure.figsize':(14,10)})
In [4]:
iris = load_iris() iris_df = pd.DataFrame(, columns=iris.feature_names) iris_df['species'] = pd.Series(,iris.target_names))) sns.pairplot(iris_df, hue='species')
In [5]:
import umap reducer = umap.UMAP()
In [6]:
embedding = reducer.fit_transform( embedding.shape
/usr/local/lib/python3.6/dist-packages/umap/ UserWarning: Embedding a total of 2 separate connected components using meta-embedding (experimental) n_components
(150, 2)
In [7]:
plt.scatter( embedding[:, 0], embedding[:, 1], c=[sns.color_palette()[x] for x in]) plt.gca().set_aspect('equal', 'datalim') plt.title('UMAP projection of the Iris dataset', fontsize=24)
Text(0.5,1,'UMAP projection of the Iris dataset')
In [ ]: