diff --git a/Orange/projection/manifold.py b/Orange/projection/manifold.py index f67874e59b0..f6eafd0d8f9 100644 --- a/Orange/projection/manifold.py +++ b/Orange/projection/manifold.py @@ -8,10 +8,6 @@ from scipy.sparse.linalg import eigsh as arpack_eigh import sklearn.manifold as skl_manifold -import openTSNE -import openTSNE.affinity -import openTSNE.initialization - import Orange from Orange.data import Table, Domain, ContinuousVariable from Orange.distance import Distance, DistanceModel, Euclidean @@ -21,9 +17,18 @@ __all__ = ["MDS", "Isomap", "LocallyLinearEmbedding", "SpectralEmbedding", "TSNE"] -# Disable t-SNE user warnings -openTSNE.tsne.log.setLevel(logging.ERROR) -openTSNE.affinity.log.setLevel(logging.ERROR) + +class _LazyTSNE: # pragma: no cover + def __getattr__(self, attr): + global openTSNE + import openTSNE + # Disable t-SNE user warnings + openTSNE.tsne.log.setLevel(logging.ERROR) + openTSNE.affinity.log.setLevel(logging.ERROR) + return openTSNE.__dict__[attr] + + +openTSNE = _LazyTSNE() def torgerson(distances, n_components=2, eigen_solver="auto"):