From b55c4f581f1b9799ed14e131fbaa7fd31bec2d13 Mon Sep 17 00:00:00 2001 From: Vesna Tanko Date: Fri, 14 Dec 2018 12:02:09 +0100 Subject: [PATCH] tSNE: Wrap fastTSNE initialization --- Orange/projection/manifold.py | 5 +++++ Orange/widgets/unsupervised/owtsne.py | 4 +--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Orange/projection/manifold.py b/Orange/projection/manifold.py index 04e701f7331..48459afc4bc 100644 --- a/Orange/projection/manifold.py +++ b/Orange/projection/manifold.py @@ -483,3 +483,8 @@ def __call__(self, data: Table) -> TSNEModel: model.name = self.name return model + + @staticmethod + def default_initialization(data, n_components=2, random_state=None): + return fastTSNE.initialization.pca( + data, n_components, random_state=random_state) diff --git a/Orange/widgets/unsupervised/owtsne.py b/Orange/widgets/unsupervised/owtsne.py index 00b98925293..0f8b3958778 100644 --- a/Orange/widgets/unsupervised/owtsne.py +++ b/Orange/widgets/unsupervised/owtsne.py @@ -3,8 +3,6 @@ from AnyQt.QtCore import Qt, QTimer from AnyQt.QtWidgets import QFormLayout -import fastTSNE.initialization - from Orange.data import Table, Domain from Orange.preprocess.preprocess import Preprocess, ApplyDomain from Orange.projection import PCA, TSNE, TruncatedSVD @@ -208,7 +206,7 @@ def __start(self): # We call PCA through fastTSNE because it involves scaling. Instead of # worrying about this ourselves, we'll let the library worry for us. - initialization = fastTSNE.initialization.pca( + initialization = TSNE.default_initialization( self.pca_data.X, n_components=2, random_state=0) # Compute perplexity settings for multiscale