<s> """<STR_LIT>""" <EOL> print ( __doc__ ) <EOL> from time import time <EOL> import numpy as np <EOL> import matplotlib . pyplot as plt <EOL> from mpl_toolkits . mplot3d import Axes3D <EOL> from matplotlib . ticker import NullFormatter <EOL> from sklearn import manifold <EOL> from sklearn . utils import check_random_state <EOL> Axes3D <EOL> n_neighbors = <NUM_LIT:10> <EOL> n_samples = <NUM_LIT:1000> <EOL> random_state = check_random_state ( <NUM_LIT:0> ) <EOL> p = random_state . rand ( n_samples ) * ( <NUM_LIT:2> * np . pi - <NUM_LIT> ) <EOL> t = random_state . rand ( n_samples ) * np . pi <EOL> indices = ( ( t < ( np . pi - ( np . pi / <NUM_LIT:8> ) ) ) & ( t > ( ( np . pi / <NUM_LIT:8> ) ) ) ) <EOL> colors = p [ indices ] <EOL> x , y , z = np . sin ( t [ indices ] ) * np . cos ( p [ indices ] ) , np . sin ( t [ indices ] ) * np . sin ( p [ indices ] ) , np . cos ( t [ indices ] ) <EOL> fig = plt . figure ( figsize = ( <NUM_LIT:15> , <NUM_LIT:8> ) ) <EOL> plt . suptitle ( "<STR_LIT>" <EOL> % ( <NUM_LIT:1000> , n_neighbors ) , fontsize = <NUM_LIT> ) <EOL> ax = fig . add_subplot ( <NUM_LIT> , projection = '<STR_LIT>' ) <EOL> ax . scatter ( x , y , z , c = p [ indices ] , cmap = plt . cm . rainbow ) <EOL> try : <EOL> ax . view_init ( <NUM_LIT> , - <NUM_LIT:10> ) <EOL> except : <EOL> pass <EOL> sphere_data = np . array ( [ x , y , z ] ) . T <EOL> methods = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> labels = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> for i , method in enumerate ( methods ) : <EOL> t0 = time ( ) <EOL> trans_data = manifold . LocallyLinearEmbedding ( n_neighbors , <NUM_LIT:2> , <EOL> method = method ) . fit_transform ( sphere_data ) . T <EOL> t1 = time ( ) <EOL> print ( "<STR_LIT>" % ( methods [ i ] , t1 - t0 ) ) <EOL> ax = fig . add_subplot ( <NUM_LIT> + i ) <EOL> plt . scatter ( trans_data [ <NUM_LIT:0> ] , trans_data [ <NUM_LIT:1> ] , c = colors , cmap = plt . cm . rainbow ) <EOL> plt . title ( "<STR_LIT>" % ( labels [ i ] , t1 - t0 ) ) <EOL> ax . xaxis . set_major_formatter ( NullFormatter ( ) ) <EOL> ax . yaxis . set_major_formatter ( NullFormatter ( ) ) <EOL> plt . axis ( '<STR_LIT>' ) <EOL> t0 = time ( ) <EOL> trans_data = manifold . Isomap ( n_neighbors , n_components = <NUM_LIT:2> ) . fit_transform ( sphere_data ) . T <EOL> t1 = time ( ) <EOL> print ( "<STR_LIT>" % ( '<STR_LIT>' , t1 - t0 ) ) <EOL> ax = fig . add_subplot ( <NUM_LIT> ) <EOL> plt . scatter ( trans_data [ <NUM_LIT:0> ] , trans_data [ <NUM_LIT:1> ] , c = colors , cmap = plt . cm . rainbow ) <EOL> plt . title ( "<STR_LIT>" % ( '<STR_LIT>' , t1 - t0 ) ) <EOL> ax . xaxis . set_major_formatter ( NullFormatter ( ) ) <EOL> ax . yaxis . set_major_formatter ( NullFormatter ( ) ) <EOL> plt . axis ( '<STR_LIT>' ) <EOL> t0 = time ( ) <EOL> mds = manifold . MDS ( <NUM_LIT:2> , max_iter = <NUM_LIT:100> , n_init = <NUM_LIT:1> ) <EOL> trans_data = mds . fit_transform ( sphere_data ) . T <EOL> t1 = time ( ) <EOL> print ( "<STR_LIT>" % ( t1 - t0 ) ) <EOL> ax = fig . add_subplot ( <NUM_LIT> ) <EOL> plt . scatter ( trans_data [ <NUM_LIT:0> ] , trans_data [ <NUM_LIT:1> ] , c = colors , cmap = plt . cm . rainbow ) <EOL> plt . title ( "<STR_LIT>" % ( t1 - t0 ) ) <EOL> ax . xaxis . set_major_formatter ( NullFormatter ( ) ) <EOL> ax . yaxis . set_major_formatter ( NullFormatter ( ) ) <EOL> plt . axis ( '<STR_LIT>' ) <EOL> t0 = time ( ) <EOL> se = manifold . SpectralEmbedding ( n_components = <NUM_LIT:2> , <EOL> n_neighbors = n_neighbors ) <EOL> trans_data = se . fit_transform ( sphere_data ) . T <EOL> t1 = time ( ) <EOL> print ( "<STR_LIT>" % ( t1 - t0 ) ) <EOL> ax = fig . add_subplot ( <NUM_LIT> ) <EOL> plt . scatter ( trans_data [ <NUM_LIT:0> ] , trans_data [ <NUM_LIT:1> ] , c = colors , cmap = plt . cm . rainbow ) <EOL> plt . title ( "<STR_LIT>" % ( t1 - t0 ) ) <EOL> ax . xaxis . set_major_formatter ( NullFormatter ( ) ) <EOL> ax . yaxis . set_major_formatter ( NullFormatter ( ) ) <EOL> plt . axis ( '<STR_LIT>' ) <EOL> t0 = time ( ) <EOL> tsne = manifold . TSNE ( n_components = <NUM_LIT:2> , init = '<STR_LIT>' , random_state = <NUM_LIT:0> ) <EOL> trans_data = tsne . fit_transform ( sphere_data ) . T <EOL> t1 = time ( ) <EOL> print ( "<STR_LIT>" % ( t1 - t0 ) ) <EOL> ax = fig . add_subplot ( <NUM_LIT:2> , <NUM_LIT:5> , <NUM_LIT:10> ) <EOL> plt . scatter ( trans_data [ <NUM_LIT:0> ] , trans_data [ <NUM_LIT:1> ] , c = colors , cmap = plt . cm . rainbow ) <EOL> plt . title ( "<STR_LIT>" % ( t1 - t0 ) ) <EOL> ax . xaxis . set_major_formatter ( NullFormatter ( ) ) <EOL> ax . yaxis . set_major_formatter ( NullFormatter ( ) ) <EOL> plt . axis ( '<STR_LIT>' ) <EOL> plt . show ( ) </s>
