<s> """<STR_LIT>""" <EOL> print ( __doc__ ) <EOL> import time <EOL> import numpy as np <EOL> import scipy as sp <EOL> import matplotlib . pyplot as plt <EOL> from sklearn . feature_extraction import image <EOL> from sklearn . cluster import spectral_clustering <EOL> from sklearn . utils . testing import SkipTest <EOL> from sklearn . utils . fixes import sp_version <EOL> if sp_version < ( <NUM_LIT:0> , <NUM_LIT:12> ) : <EOL> raise SkipTest ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> try : <EOL> face = sp . face ( gray = True ) <EOL> except AttributeError : <EOL> from scipy import misc <EOL> face = misc . face ( gray = True ) <EOL> face = sp . misc . imresize ( face , <NUM_LIT> ) / <NUM_LIT> <EOL> graph = image . img_to_graph ( face ) <EOL> beta = <NUM_LIT:5> <EOL> eps = <NUM_LIT> <EOL> graph . data = np . exp ( - beta * graph . data / graph . data . std ( ) ) + eps <EOL> N_REGIONS = <NUM_LIT> <EOL> for assign_labels in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> t0 = time . time ( ) <EOL> labels = spectral_clustering ( graph , n_clusters = N_REGIONS , <EOL> assign_labels = assign_labels , random_state = <NUM_LIT:1> ) <EOL> t1 = time . time ( ) <EOL> labels = labels . reshape ( face . shape ) <EOL> plt . figure ( figsize = ( <NUM_LIT:5> , <NUM_LIT:5> ) ) <EOL> plt . imshow ( face , cmap = plt . cm . gray ) <EOL> for l in range ( N_REGIONS ) : <EOL> plt . contour ( labels == l , contours = <NUM_LIT:1> , <EOL> colors = [ plt . cm . spectral ( l / float ( N_REGIONS ) ) ] ) <EOL> plt . xticks ( ( ) ) <EOL> plt . yticks ( ( ) ) <EOL> title = '<STR_LIT>' % ( assign_labels , ( t1 - t0 ) ) <EOL> print ( title ) <EOL> plt . title ( title ) <EOL> plt . show ( ) </s>
