Module Expr Str Print NameLoad Import alias Import alias identifier Import alias identifier Import alias identifier ImportFrom alias ImportFrom alias ImportFrom alias ImportFrom alias If CompareLt NameLoad TupleLoad Num Num body Raise Call NameLoad Str TryExcept body Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad handlers ExceptHandler type NameLoad body ImportFrom alias Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad Assign NameStore BinOpDiv Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Num Num Assign NameStore Call AttributeLoad NameLoad attr NameLoad Assign NameStore Num Assign NameStore Num Assign AttributeStore NameLoad attr BinOpAdd Call AttributeLoad NameLoad attr BinOpDiv BinOpMult UnaryOpUSub NameLoad AttributeLoad NameLoad attr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad Assign NameStore Num For NameStore TupleLoad Str Str body Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call NameLoad NameLoad keyword NameLoad keyword NameLoad keyword Num Assign NameStore Call AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr keyword TupleLoad Num Num Expr Call AttributeLoad NameLoad attr NameLoad keyword AttributeLoad AttributeLoad NameLoad attr attr For NameStore Call NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr CompareEq NameLoad NameLoad keyword Num keyword ListLoad Call AttributeLoad AttributeLoad NameLoad attr attr BinOpDiv NameLoad Call NameLoad NameLoad Expr Call AttributeLoad NameLoad attr TupleLoad Expr Call AttributeLoad NameLoad attr TupleLoad Assign NameStore BinOpMod Str TupleLoad NameLoad BinOpSub NameLoad NameLoad Print NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr
N/A N/A 
===================================================
Segmenting the picture of a raccoon face in regions
===================================================

This example uses :ref:`spectral_clustering` on a graph created from
voxel-to-voxel difference on an image to break this image into multiple
partly-homogeneous regions.

This procedure (spectral clustering on an image) is an efficient
approximate solution for finding normalized graph cuts.

There are two options to assign labels:

* with 'kmeans' spectral clustering will cluster samples in the embedding space
  using a kmeans algorithm
* whereas 'discrete' will iteratively search for the closest partition
  space to the embedding space.
 N/A __doc__ N/A time N/A numpy np N/A scipy sp N/A matplotlib.pyplot plt sklearn.feature_extraction image sklearn.cluster spectral_clustering sklearn.utils.testing SkipTest sklearn.utils.fixes sp_version N/A N/A sp_version N/A 0 12 N/A N/A N/A SkipTest Skipping because SciPy version earlier than 0.12.0 and thus does not include the scipy.misc.face() image. N/A N/A N/A face N/A N/A sp face gray True N/A N/A N/A AttributeError N/A scipy misc N/A face N/A N/A misc face gray True N/A face N/A N/A N/A N/A sp misc imresize face 0.1 255.0 N/A graph N/A N/A image img_to_graph face N/A beta 5 N/A eps 1e-06 N/A N/A graph data N/A N/A N/A np exp N/A N/A N/A beta N/A graph data N/A N/A N/A graph data std eps N/A N_REGIONS 25 N/A assign_labels N/A kmeans discretize N/A N/A t0 N/A N/A time time N/A labels N/A spectral_clustering graph n_clusters N_REGIONS assign_labels assign_labels random_state 1 N/A t1 N/A N/A time time N/A labels N/A N/A labels reshape N/A face shape N/A N/A N/A plt figure figsize N/A 5 5 N/A N/A N/A plt imshow face cmap N/A N/A plt cm gray N/A l N/A range N_REGIONS N/A N/A N/A N/A plt contour N/A labels l contours 1 colors N/A N/A N/A N/A plt cm spectral N/A l N/A float N_REGIONS N/A N/A N/A plt xticks N/A N/A N/A N/A plt yticks N/A N/A title N/A Spectral clustering: %s, %.2fs N/A assign_labels N/A t1 t0 N/A title N/A N/A N/A plt title title N/A N/A N/A plt show