mac上MulticoreTSNE安装及测试

直接输入

pip install MulticoreTSNE

会出现以下错误
解决办法:

pip install cmake==3.18.4
##### 测试代码
python
from MulticoreTSNE import MulticoreTSNE as TSNE

不要安装最新的cmake,否则会出错误
最终测试
mac上MulticoreTSNE安装及测试_第1张图片

测试速度

测试load_digit数据集

这个是我在服务器上跑的

from sklearn.datasets import load_digits
from MulticoreTSNE import MulticoreTSNE as TSNE
from matplotlib import pyplot as plt

digits=load_digits()
embeddings=TSNE(n_jobs=8).fit_transform(digits.data)
vis_x=embeddings[:,0]
vis_y=embeddings[:,1]
plt.scatter(vis_x,vis_y,c=digits.target,cmap=plt.cm.get_cmap("jet",10),marker=".")
plt.colorbar(ticks=range(10))
plt.clim(-0.5,9.5)
plt.show()

mac上MulticoreTSNE安装及测试_第2张图片

测试mnist数据集

%%time
import numpy as np
from MulticoreTSNE import MulticoreTSNE as TSNE
from matplotlib import pyplot as plt
if __name__ == "__main__":
    data=np.load("/DATA1/zhangjingxiao/yxk/dataset/mnist/mnist.npz")
    for item in data.files:
        print(item)# find keys,the you can get value
        print(data[item].shape)
        print("=================")
    ## follow this

    X=data["x_train"].reshape(60000,-1)
    y=data["y_train"]
    print(X.shape)

    embeddings=TSNE(n_jobs=8).fit_transform(X)
    vis_x=embeddings[:,0]
    vis_y=embeddings[:,1]
    plt.scatter(vis_x,vis_y,c=y)
    plt.show()

mac上MulticoreTSNE安装及测试_第3张图片但是我使用sklearn里的TSNE计算发现速度并没有提高

%%time
import numpy as np
from sklearn.manifold import TSNE 
#from MulticoreTSNE import MulticoreTSNE as TSNE
from matplotlib import pyplot as plt

data=np.load("/DATA1/zhangjingxiao/yxk/dataset/mnist/mnist.npz")
for item in data.files:
    print(item)# find keys,the you can get value
    print(data[item].shape)
    print("=================")
## follow this

X=data["x_train"].reshape(60000,-1)
y=data["y_train"]
print(X.shape)

tsne = TSNE(n_components=2, init='pca', random_state=0)
embeddings= tsne.fit_transform(X)
vis_x=embeddings[:,0]
vis_y=embeddings[:,1]
plt.scatter(vis_x,vis_y,c=y)
plt.show()

结果如下
mac上MulticoreTSNE安装及测试_第4张图片
发现时间基本上是差不多的,好奇怪啊,没有任何加速的现象吗,

你可能感兴趣的:(可视化,python,python)