def test_optimization_minimizes_kl_divergence():
 random_state = check_random_state(0)
 (X, _) = make_blobs(n_features=3, random_state=random_state)
 kl_divergences = []
 for n_iter in [200, 250, 300]:
  tsne = TSNE(n_components=2, perplexity=10, learning_rate=100.0, n_iter=n_iter, random_state=0)
  tsne.fit_transform(X)
  kl_divergences.append(tsne.kl_divergence_)
 assert_less_equal(kl_divergences[1], kl_divergences[0])
 assert_less_equal(kl_divergences[2], kl_divergences[1])

def test_optimization_minimizes_kl_divergence ( ) : random_state = check_random_state ( 0 ) ( X , _ ) = make_blobs ( n_features = 3 , random_state = random_state ) kl_divergences = [ ] for n_iter in [ 200 , 250 , 300 ] : tsne = TSNE ( n_components = 2 , perplexity = 10 , learning_rate = 100.0 , n_iter = n_iter , random_state = 0 ) tsne . fit_transform ( X ) kl_divergences . append ( tsne . kl_divergence_ ) assert_less_equal ( kl_divergences [ 1 ] , kl_divergences [ 0 ] ) assert_less_equal ( kl_divergences [ 2 ] , kl_divergences [ 1 ] )
t-sne should give a lower kl divergence with more iterations .