Python
t-sne
More than 1 year has passed since last update.

3次元の配列を2次元にする

import numpy as np
from sklearn.manifold import TSNE

# 3次元の配列を2次元にする
X = np.array([[0, 0, 0], [0, 1, 1], [1, 0, 1], [1, 1, 1]])

model = TSNE(n_components=2, random_state=0)
np.set_printoptions(suppress=True)
result = model.fit_transform(X) 

print( result )
[[ 0.00017599  0.00003993]
 [ 0.00009891  0.00021913]
 [ 0.00018554 -0.00009357]
 [ 0.00009528 -0.00001407]]

n次元の配列を3次元にする

import numpy as np
from sklearn.manifold import TSNE

# 5次元の配列を3次元にする
X = np.array([[0, 0, 0, 0, 0], [0, 1, 1, 0, 0], [1, 0, 1, 0, 0], [1, 1, 1, 0, 0]])

model = TSNE(n_components=3, random_state=0)
np.set_printoptions(suppress=True)
result = model.fit_transform(X) 

print( result )
[[ 0.00017664  0.00004092  0.00010137]
 [ 0.00022378  0.0001879  -0.00010256]
 [ 0.00009511 -0.00001756 -0.00001262]
 [ 0.00004055  0.00001404  0.00014699]]

sklearn.manifold.TSNE — scikit-learn 0.18.1 documentation
http://scikit-learn.org/stable/modules/generated/sklearn.manifold.TSNE.html