Y : np.ndarray
tSNE representation of the data.
params = locals(); del params["adata"]
sett.m(0,"perform tSNE")
sett.m(0,"--> mind that this is not deterministic!")
// preprocessing by PCA
if "X_pca" in adata:
X = adata["X_pca"]
sett.m(0, "using X_pca for tSNE")
else:
if params["n_pcs"] > 0 and adata.X.shape[1] > params["n_pcs"]:
sett.m(0, "preprocess using PCA with", params["n_pcs"], "PCs")
sett.m(0, "--> avoid this by setting n_pcs = 0")
dpca = pca(adata, n_comps=params["n_pcs"])
After Change
if n_pcs > 0 and adata.X.shape[1] > n_pcs:
sett.m(0, "preprocess using PCA with", n_pcs, "PCs")
sett.m(0, "--> avoid this by setting n_pcs = 0")
X = pca(adata.X, n_comps=n_pcs)
adata["X_pca"] = X
else:
X = adata.X
// params for sklearn
params_sklearn = {"perplexity" : perplexity}
params_sklearn["verbose"] = sett.verbosity
// deal with different tSNE implementations
try:
from MulticoreTSNE import MulticoreTSNE as TSNE
tsne = TSNE(n_jobs=4, **params_sklearn)
sett.m(0,"... compute tSNE using MulticoreTSNE")
Y = tsne.fit_transform(X)
except ImportError:
try:
from sklearn.manifold import TSNE
tsne = TSNE(**params_sklearn)
sett.m(1,"--> perform tSNE using sklearn!")
sett.m(1,"--> can be sped up by installing\n"
" https://github.com/DmitryUlyanov/Multicore-TSNE")
Y = tsne.fit_transform(X)
except ImportError:
sett.m(0,"--> perform tSNE using slow/unreliable original\n"
" code by L. van der Maaten!?\n"
"--> consider installing sklearn\n"
" using "conda/pip install scikit-learn"")
Y = _tsne_vandermaaten(X, 2, params["perplexity"])
adata["X_tsne"] = Y
return adata
def plot(adata,