定义TSNE,这里是二维的。所以n_components=2 def TSNE(data): start = time.time() tsne = manifold.TSNE(n_components=2, init='pca', random_state=501) datat_tsne = tsne.fit_transform(data) # 归一化 x_min, x_max = datat_tsne.min(0), datat_tsne.max(0) X_norm = (datat_tsne - ...
init 初始化,默认为random。取值为random为随机初始化,取值为pca为利用PCA进行初始化(常用),取值为numpy数组时必须shape=(n_samples, n_components) verbose 是否打印优化信息,取值0或1,默认为0=>不打印信息。打印的信息为:近邻点数量、耗时、σ、KL散度、误差等 random_state 随机数种子,整数或RandomState对象 met...
importnumpyasnpimportmatplotlib.pyplotaspltfromsklearnimportmanifold,datsets'''X是特征,不包含target;X_tsne是已经降维之后的特征'''tsne = manifold.TSNE(n_components=2, init='pca', random_state=501) X_tsne = tsne.fit_transform(X)print("Org data dimension is {}. Embedded data dimension is {...