Wednesday, March 16, 2022

Project data into 3D with t-SNE and px.scatter_3d

 t-SNE может уменьшить ваши данные до любого количества измерений, которое вы хотите! Здесь мы покажем вам, как спроецировать его в 3D и визуализировать с помощью 3D-диаграммы рассеяния.

Code1

from sklearn.manifold import TSNE

import plotly.express as px

import warnings

warnings.simplefilter(action='ignore', category=FutureWarning)

df = px.data.iris()

features = df.loc[:, :'petal_width']

tsne = TSNE(n_components=3, random_state=10)

projections = tsne.fit_transform(features, )

fig = px.scatter_3d(

    projections, x=0, y=1, z=2,

    color=df.species, labels={'color': 'species'}

)

fig.update_traces(marker_size=8)

fig.show()

**************
Code 2
**************

from sklearn.manifold import TSNE

import plotly.express as px

import warnings

warnings.simplefilter(action='ignore', category=FutureWarning)

df = px.data.iris()

features = df.loc[:, :'petal_width']

tsne = TSNE(n_components=3, random_state=1000)

projections = tsne.fit_transform(features, )

fig = px.scatter_3d(

    projections, x=0, y=1, z=2,

    color=df.species, labels={'color': 'species'}

)

fig.update_traces(marker_size=8)

fig.show()


Case 1 : First run random_state=10

















Case 1 Second run :  random_state=10















Case 2 : First run random_state=1000
















Refences

https://plotly.com/python/t-sne-and-umap-projections/

No comments:

Post a Comment