高维数据的 t-SNE 可视化

Python 中的降维

Jeroen Boeye

Head of Machine Learning, Faktion

IRIS 数据集上的 t-SNE

鸢尾花聚类

Python 中的降维

IRIS 数据集上的 t-SNE

鸢尾花聚类(标注 1)

Python 中的降维

IRIS 数据集上的 t-SNE

鸢尾花聚类(物种)

Python 中的降维

女性 ANSUR 数据集上的 t-SNE

df.shape
(1986, 99)
non_numeric = ['BMI_class', 'Height_class', 
               'Gender',  'Component', 'Branch']

df_numeric = df.drop(non_numeric, axis=1)

df_numeric.shape
(1986, 94)
Python 中的降维

拟合 t-SNE

from sklearn.manifold import TSNE

m = TSNE(learning_rate=50)
tsne_features = m.fit_transform(df_numeric)

tsne_features[1:4,:]
array([[-37.962185,  15.066088],
       [-21.873512,  26.334448],
       [ 13.97476 ,  22.590828]], dtype=float32)
Python 中的降维

将 t-SNE 特征赋给数据集

tsne_features[1:4,:]
array([[-37.962185,  15.066088],
       [-21.873512,  26.334448],
       [ 13.97476 ,  22.590828]], dtype=float32)
df['x'] = tsne_features[:,0]

df['y'] = tsne_features[:,1]
Python 中的降维

绘制 t-SNE 图

import seaborn as sns

sns.scatterplot(x="x", y="y", data=df)

plt.show()
Python 中的降维

绘制 t-SNE 图

ansur 点云

Python 中的降维

按 BMI 类别着色

import seaborn as sns
import matplotlib.pyplot as plt

sns.scatterplot(x="x", y="y", hue='BMI_class', data=df)

plt.show()
Python 中的降维

按 BMI 类别着色

ansur 点云(BMI)

Python 中的降维

按 BMI 类别着色

ansur 点云(BMI 标注)

Python 中的降维

按身高类别着色

import seaborn as sns

import matplotlib.pyplot as plt

sns.scatterplot(x="x", y="y", hue='Height_class', data=df)

plt.show()
Python 中的降维

按身高类别着色

ansur 点云(身高)

Python 中的降维

按身高类别着色

ansur 点云(双标注)

Python 中的降维

开始练习吧!

Python 中的降维

Preparing Video For Download...