def test_pca_init_with_only_affinities_passed(self): aff = affinity.PerplexityBasedNN(self.x, 5, method="exact") desired_init = initialization.spectral(aff.P) embedding = TSNE(early_exaggeration_iter=0, n_iter=0, initialization="pca").fit(affinities=aff) np.testing.assert_array_equal(embedding, desired_init)
def test_precomputed_dist_matrix_via_affinities_uses_spectral_init(self): x = np.random.normal(0, 1, (200, 5)) d = squareform(pdist(x)) aff = affinity.PerplexityBasedNN(d, metric="precomputed") desired_init = initialization.spectral(aff.P) embedding = TSNE(early_exaggeration_iter=0, n_iter=0).fit(affinities=aff) np.testing.assert_array_equal(embedding, desired_init)