From c21d8d053f40b6954e71438fea2af44c9460ebb1 Mon Sep 17 00:00:00 2001 From: Olivier Grisel <olivier.grisel@ensta.org> Date: Wed, 24 Aug 2011 12:25:46 +0200 Subject: [PATCH] update the documentation --- doc/datasets/index.rst | 25 +++++++++++++++++++ .../cluster/{vq_china.py => plot_vq_china.py} | 24 ++++++++++-------- 2 files changed, 38 insertions(+), 11 deletions(-) rename examples/cluster/{vq_china.py => plot_vq_china.py} (79%) diff --git a/doc/datasets/index.rst b/doc/datasets/index.rst index 8e2b3531db..18c66b8975 100644 --- a/doc/datasets/index.rst +++ b/doc/datasets/index.rst @@ -47,6 +47,31 @@ These datasets are useful to quickly illustrate the behavior of the various algorithms implemented in the scikit. They are however often too small to be representative of real world machine learning tasks. +Sample images +============= + +The scikit also embed a couple of sample JPEG images published under Creative +Commons license by their authors. Those image can be useful to test algorithms +and pipeline on 2D data. + +.. autosummary:: + + load_sample_images + load_sample_image + +.. note:: + + The default coding of images is based on the ``uint8`` dtype to + spare memory. Often machine learning algorithms work best if the + input is converted to a floating point representation first. Also, + if you plan to use ``pylab.imshow`` don't forget to scale to the range + 0 - 1 as done in the following example. + +.. topic:: Examples: + + * :ref:`example_cluster_plot_vq_china.py` + + Sample generators ================= diff --git a/examples/cluster/vq_china.py b/examples/cluster/plot_vq_china.py similarity index 79% rename from examples/cluster/vq_china.py rename to examples/cluster/plot_vq_china.py index 1c19e10339..8518f1b1e6 100644 --- a/examples/cluster/vq_china.py +++ b/examples/cluster/plot_vq_china.py @@ -1,11 +1,11 @@ # -*- coding: utf-8 -*- """ -========================================= -Vector Quantization of Lena using k-means -========================================= +============================================ +Vector Quantization of a photo using k-means +============================================ -Performs a Vector Quantization of an image, reducing the number of colors -required to show the image. +Performs a pixel-wise Vector Quantization of an image, reducing the number of +colors required to show the image while preserving the overall appearance. """ print __doc__ import numpy as np @@ -52,13 +52,15 @@ def recreate_image(codebook, labels, w, h): return image # Display all results, alongside original image -pl.figure() -ax = pl.axes([0, 0, 1, 1], frameon=False) -ax.set_axis_off() +pl.figure(1) +pl.clf() +ax = pl.axes([0, 0, 1, 1]) +pl.axis('off') pl.imshow(china) -pl.figure() -ax = pl.axes([0, 0, 1, 1], frameon=False) -ax.set_axis_off() +pl.figure(2) +pl.clf() +ax = pl.axes([0, 0, 1, 1]) +pl.axis('off') pl.imshow(recreate_image(kmeans.cluster_centers_, labels, w, h)) pl.show() -- GitLab