Spaces:
Sleeping
Sleeping
from sklearn.preprocessing import RobustScaler | |
import seaborn as sns | |
import umap | |
import thisnotthat as tnt | |
import panel as pn | |
pn.extension('tabulator') | |
penguins = ( | |
sns.load_dataset('penguins') | |
.dropna() | |
.rename( | |
columns={ | |
"bill_length_mm": "bill-length", | |
"bill_depth_mm": "bill-depth", | |
"flipper_length_mm": "flipper-length", | |
"body_mass_g": "body-mass" | |
} | |
) | |
) | |
data_for_umap = RobustScaler().fit_transform(penguins.select_dtypes(include="number")) | |
penguin_datamap = umap.UMAP(random_state=42).fit_transform(data_for_umap) | |
basic_plot = tnt.BokehPlotPane( | |
penguin_datamap, | |
labels=penguins.species, | |
hover_text=penguins.select_dtypes(include="object").apply(" ".join, axis=1), | |
width=800 | |
) | |
pn.Row(basic_plot).servable | |